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?

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

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.

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