On Sun, Oct 2, 2011 at 10:47 PM, Damian Steer <[email protected]> wrote:
> > 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.gi <https://gist.github.com/1257922> *Thanks Damian, * * > * *I will hopefully have time to test this code next week! It looks good as * thub.com/1257922 <https://gist.github.com/1257922>> Hi Damian, Thanks a lot for this contribution! I will have time to test this code next week -- It looks good, I almost gave up hope :-) comment says you'd be happier to use stream reader, now it is using XMLEventReader -- but isn't this also streaming? It's still not like DOM, right? Maybe i'll be able to escape the event stream (when I finished the relevant RDF/XML sub-part) by throwing an exception -- what do you think? (I'm not very experienced with XML processing). Any suggestions are more than welcome! Cheers Eric
