On 30 Sep 2011, at 10:55, Eric Feliksik wrote:

> I am using the Stax parser to process my document. As soon as i find the
> <myGraphAnnouncer> tag, I want to hand the responsibility of parsing to Jena
> as it already implements this.
> Is there a Stax implementation that I could directly pass the stax
> javax.xml.stream.XMLStreamReader ? 


> Does Jena have a Stax RDF parsing implementation? If not, do you have any
> advice? Thanks in advance!
> Regards,
> Eric

Hi Eric,

ARP (Jena's RDF/XML parser) uses SAX, not StAX. However it ought to be fairly 
easy to move between to two, since you just need to pull all the events and 
pass them on to a content handler.

Looking around there seem to quite a few StAX / SAX converters in various 
projects, however the ones I could track down didn't seem to work. (I also 
tried a favourite XSLT identity transform trick, but it exploded)

So here's a mostly working (for ARP) version I wrote. [1] Use it in the 
following way:

SAX2Model s2m = SAX2Model.create(baseuri, model);  // ARP
StAX2SAX converter = new StAX2SAX(s2m);
converter.parse(xmlStreamReader);

Hope it works ok. Might be worth adding to jena.

Damian

[1] <https://gist.github.com/1257922>

Reply via email to