Thankyou Damian, 

I did not know the option.
Unfortunately, I tried it and it does not change the result.

I agree with your second advise and I follow it:
I already tried to pass in the DOM node corresponding to the sub-tree to the 
load operation, but I did not navigate in my object model down to the right 
level:

      Document d = (Document)resource;
      for (MediaUnit mu: ((Document)resource).getMediaUnit()) {
        for (Annotation annot: mu.getAnnotation()) {
          org.apache.xerces.dom.ElementImpl dataElement = 
(org.apache.xerces.dom.ElementImpl)annot.getData();
          // load only the sub tree  <data><rdf:RDF ...
          arp.load(dataElement); // wrong!

I just add the following line:
          org.w3c.dom.Node rdfNode = dataElement.getFirstChild();

And now
          // load only the sub tree  <rdf:RDF ...
            arp.load(rdfNode); // allright!

I reach the right level and it works! I now reads the 9 triples.

Thanks

Olivier 
 


Le mardi 13 septembre 2011 15:01:26, Damian Steer a écrit :
> On 13 Sep 2011, at 13:23, Olivier Mesnard wrote:
> > Dear Everyone,
> 
> Hi Olivier,
> 
> > I have some difficulties with the load() operation of class
> > com.hp.hpl.jena.rdf.arp.DOM2Model.
> > The operation seems to performs incompletely its task and I don't know
> > what is wrong with my code. perhaps I miss some options of the parser.
> 
> I think there is an option for this
> 
> > Here is the code:
> 
> <snip>
> 
> >            DOM2Model arp = DOM2Model.createD2M("", _model);
> >            arp.allowRelativeURIs();
> 
> Try:
> 
> arp.getOptions().setEmbedding(true);
> 
> From the javadoc: [1]
> 
> "Sets whether the XML document is only RDF, or contains RDF embedded in
>  other XML. The default is non-embedded mode. Embedded mode also matches
>  RDF documents that use the rdf:RDF tag at the top-level. Non-embeded mode
>  matches RDF documents which omit that optional tag, and consist of a
>  single rdf:Description or typed node. To find embedded RDF it is necessary
>  to setEmbedding(true)."
> 
> Which sounds like what you want.
> 
> (As an alternative you could pass in the DOM node corresponding to the
>  sub-tree you want to parse. Your issue is that you're trying to parse the
>  whole thing as RDF/XML)
> 
> Damian
> 
> [1]
>  <http://jena.sourceforge.net/javadoc/com/hp/hpl/jena/rdf/arp/ARPOptions.ht
> ml#setEmbedding(boolean)>
> 

Reply via email to