On 24/04/15 20:00, souri datta wrote:
Hi,
  When  I am parsing an N-quad using Jena, is it possible to keep the blank
node id same after parsing?

For e.g., if I have a blank n-quad like

_:bsomerandomid   <ns:pred>    <http://foo.com>  <foo> .

After parsing, when I do

subject.getBlankNodeId() it runs a randomly generated string which is
different from "_:bsomerandomid" .

Is it possible to set some flags so that I get blank the same id as present
in the input quad?

Hi,

As David say, blank nodes are not for identification so maybe you need some kind of stable label liek a <urn:uuid:....>

Warning - if you work with the blanknode labels as given you will not be following RDF. "_:a" in one file is different to "_:a" in another file or even if the same file is read twice.

With your code (*) I get

bsomerandomid

The "_:" is not part of the blank node id.

"createUseLabelEncoded" generates legal blank node labels directly related to the string given.

The correct form generates a globally unique id that never clashes with any other (well, its related to a 122 bit random number).

Please take care with code next time - HTML gets converted and formatted HTML is messed up.

        Andy



Thanks,
Souri



*Code used:*
*private ParserProfileBase profile = new ParserProfileBase(new
Prologue(null,*
*            IRIResolver.createNoResolve()),*
*            ErrorHandlerFactory.errorHandlerStrictSilent(),*
*            LabelToNode.createUseLabelEncoded());*
*    profile.setStrictMode(true);*
*}*
*List<Quad> output = new ArrayList<>();*
*Tokenizer tokenizer = TokenizerFactory.makeTokenizerString(line);*
*LangNQuads parser = new LangNQuads(tokenizer, profile, null);*
* while (parser.hasNext()) {*
*        output.add(parser.next());*
* }*
* output.get(0).getSubject().getBlankNodeId();*


Reply via email to