ohhh... this is embarrassing, I was originally using NodeFactory.parseNode (in 
my own code) and had some bad data while debugging that threw me for a loop.  I 
thought it wasn't working with literals.

So my bad data was:
0.01^^xsd:float
which gave me:
com.hp.hpl.jena.sparql.sse.SSEParseException: Not a node: 0.01^^xsd:float
    at com.hp.hpl.jena.sparql.sse.SSE.parseNode(SSE.java:283)

I didn't realize at first that it was missing the quotations, ( 
"0.01"^^xsd:float ) and falsely assumed parseNode() does not parse literals 
(learning curve I guess)...  which led me on a goose chase back to parseNode()

Thanks for setting me straight,
Tim


----- Original Message ----
> From: Andy Seaborne <[email protected]>
> To: [email protected]
> Sent: Fri, June 17, 2011 1:17:01 AM
> Subject: Re: parsing RDF literals
> 
> 
> 
> On 17/06/11 08:55, Paolo Castagna wrote:
> > Hi Andy (hi  all),
> > we've seen recently different people asking for a similar  question.
> >
> > Given that there are different ways, what would be the  best|recommended
> > way?
> > Or, what are pros/cons of the different  ways?
> >
> >  From an user perspective, shouldn't we promote the  NodeFactory approach,
> > so that we can switch implementation without  disruption for users?
> 
> That's why NodeFactory.paseNode is there!
> 
> If  you look at the call huierarchiy, you'll see many 
> NodeFactory.apsreNode  calls, few SSE.parseNode.
> 
> So the contents of NodeFactory.parseNode can be  chnaged.  It abstracts 
> the implementation from the use.
> 
> >  NodeFactory is currently using SSE.parseNode(...):
> >
> > public static  Node parseNode(String nodeString)
> > {
> > return  SSE.parseNode(nodeString) ;
> > }
>  >
> > Therefore, we have two  ways: SSE (old) vs. RIOT's Tokenizer(s) (new).
> > The assumption is that  'new' is better|faster than 'old'. :-)
> > Is the plan to move from SSE to  RIOT's Tokenizer(s)?
> >
> > I tried, just for curiosity, to replace SSE  with RIOT's Tokenizer in
> > the NodeFactory implementation parseNode  method:
> >
> > public static Node parseNode(String nodeString)
> >  {
> > return  TokenizerFactory.makeTokenizerString(nodeString).next().asNode() ;
> >  }
> >
> > ... we have a few failures and errors, precisely:
> >  Tests run: 3865, Failures: 41, Errors: 56, Skipped: 0
> 
> If you look at the  errors and failures, I hope you'll see a common pattern.
> 
> SSE has default  prefixes builtin.
> 
> >
> > Not, many, be there is clearly something  to do and the two are not
> > functionally
> > equivalent (yet). Maybe  this is an opportunity for someone who might
> > wants to
> > help.  :-)
> >
> > Sorry, for all these questions, but I imagine others have  similar
> > questions in relation to String -> Node and Node -> String  conversion.
> 
> I'm less sure that it is that.
> 
> String -> Node  happens in context.
> 
> It a matter of language design which is what RIOT can  help with.
> Many of the calls in NodeFactory.parseNode are in testing in  ARQ.
> 
> The question you might ask Tim is where did the string come  from?
> 
>     Andy
> 
> >
> > Thank you,
> >  Paolo
> >
> >
> > Andy Seaborne wrote:
> >>  Tim,
> >>
> >> There's a NodeFactory  static:
> >>
> >> com.hp.hpl.jena.sparql.util.
> >>  NodeFactory.parseNode(String str)
> >>
> >> Theer is also the  older way Node SSE.parseNode(String) which taps into
> >> the SSE [*]  parser. SSE is an odd name for this - code ended up there
> >> and it  just stayed there.
> >>
> >> The other way  is:
> >>
> >> TokenizerFactory.makeTokenizerString("...").next()  ;
> >>
> >> Tokenizers give varuious ways to handle a stream of  tokens. One way is
> >> from a string.
> >>
> >>  Andy
> >>
> >> [*]  http://openjena.org/wiki/SSE
> >>
> >> On 17/06/11 00:58, Tim  Harsch wrote:
> >>> If I have text in any of the various supported  forms for RDF
> >>> literals. What
> >>> method can I call  to parse that text into a Node_Literal? It should
> >>> be able  to
> >>> recognize the lang tag and the typed literal string and  act
> >>> appropriately. I've
> >>> found  NodeFactory.createLiteralNode(String lex, String lang, String
> >>>  datatypeURI)
> >>> but it requires you've already parsed the literal  into its lexical
> >>> form, lang
> >>> tag and datatypeURI  to use...
> >>>
> >>> Thanks,
> >>>  tim
> >
> 

Reply via email to