From: Tatu S. <cow...@ya...> - 2006-08-02 22:05:05
|
--- Din Sush <di...@ya...> wrote: > Hi, > I have explored woodstox also, issue with STAX > parsers that I am having is I need to build complete > xml, > whereas in vtd or sax i can get the fragment and > write it to a file. I'm pretty sure you are confusing SAX and DOM here... since SAX only gives you individual nodes, similar to what StAX does, not subtrees (you can of course reconstruct sub-trees from events, but that's not the same thing). So, I assume you mean 'VTD or DOM'. But I'm not quite sure what would be complicated in building XML using Event API of Stax (it is bit more complicated if using raw cursor API, ie. XMLStreamReader and XMLStreamWriter -- maybe you have only used it so far?). With Event API It's just events in and events out. Bit of recursion for copying, and that's pretty much it, for simple merging. ... > Now I want to put say 10 person records in file 1and > so on, with vtd, i will get the fragment and I will > write that to file, with sax also I can get entire If bitwise exact copy does work, yes. This is not necessarily the case if namespaces are used (or if DTD-based entities are used). > person record, but with SAX, I don't get the > complete > person record. So I have to create a XMLWriter, use, > functions like writeStartElement, writeAttribute, > etc. > Basically building the entire structure which is > already there. Yes. That's streaming. With XMLEventWriter you just add XMLEvents you get from XMLEventReader, but you do need to pipe them through, looping. Bit more work, but not a lot (just need to keep track of pairing start/end tags). -+ Tatu +- __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |