Re: xmlwriter and xmlfilter
Luca Dall'Olio <[email protected]>
| Newsgroups | gmane.comp.java.classpath.extensions.xml |
|---|---|
| Message-ID | <[email protected]> |
Nic Ferrier wrote: > Luca Dall'Olio <[email protected]> writes: > > >>I am on thesis on archiving *huge* quantities of xml-signed data. >>Among other things I have to write a single xml file more than 4 Gb size >>(1 dvd) so I decided to use Sax. >> >>Since the Xerces default content handler does not have a flush() method >>(it keeps everything in memory until the endDocument() method call), I >>changed to Dom4j XmlWriter and then I changed again to Gnu Jaxp >>XmlWriter, because Dom4j does not produce canonalized output. >>Now I would like to send the canonalized sax events to a digester in >>order to produce the document hash and then prettyprint the sax events >>into an outputstream (the final file). >> >>First question: >>Do you think that I chose the right approach? > > > Broadly, yes. > > > >>Second one: >>How can I send the XmlWriter events through an XmlFilter (I would prefer >>not to use the Gnu Jaxp pipeline package: I would like to write >>implementation independent code as far as possible), since XmlWriter >>does not implement the XmlReader interface? Should I extend the >>XmlWriter to do implement it? > > > Why can't you filter the events before they get to the XmlWriter? > using an ordinary SAX chain > > > Nic > > > I could not understand why XmlFilter has to be at the end of the event chain, now I do. I cannot use an ordinary SAX chain because I need to produce both Pretty Printed and Canonicalized Xml at the same time, in order to write a nice .xml file and calculate an hash out of it. My actual solution (it works!) is to fire SAX events using a TeeConsumer and then serialize with a couple of TextConsumers. Thank you very much for your helpful suggestions! Luca Dall'Olio