We're working now on defining a serializer API that will be supported by more than just Xerces. That API has to live with the constraints of other implementations, and one of the definitions is that a serializer is good for serializing just one document.
To reuse a serializer you need to define one of two things: 1. How to let the serializer know it is being recycled 2. How to let the serializer know it's not longer being used These two methods calls are required by a DocumentHandler/ContentHandler implementation, and the DOMSerializer will use the same pattern, to allow a DOMSerializer to be built using a DOM tree walking and SAX serializer. How these calls will look like is undefined, so whatever manner you're using to recycle the serializer is subject to change. The Xerces serialized can be reused any number of times, in fact, they were designed to be pooled, there's just not final definition of how you pool them. Calling either setOutputFormat or setOutputStream will reset the serializer, so you can use it with a different document/stream/format, and you can reuse it any number of times. But this behavior is subject to change in the future. arkin Arnaud Le Hors wrote: > > Assaf Arkin wrote: > > > > By definition a serializer is good for printing just one document, and > > it prints just one document. > > "By definition"? Sorry, I don't understand. Do you actually simply mean > that you didn't design/implement the serializer to print more than one > document? It that's it, I can understand (even though I think it's > unfortunate ;-). > > > Although it's possible to print two documents with domSerializer, I'm > > not sure if it makes sense with a DocumentHandler/ContentHandler, so I > > would advise against it. > > Could you expand on this a bit and tell us why? For one thing, people > expect to be able to reuse the parser, so why would it be unreasonable > to expect the same from the serializer? > Thanks. > -- > Arnaud Le Hors - IBM Cupertino, XML Technology Group -- ---------------------------------------------------------------------- Assaf Arkin www.exoffice.com CTO, Exoffice Technologies, Inc. www.exolab.org
