When the depth tree drops back to 0, the serializer assumes you're done for the day and flushes the output.
But, it doesn't assume you're starting a new document, which is nice if you print multiple nodes in the same document (i.e. not single root element). Why would you want to do that? To serialize an external entity. There's also a question of who gets to pool the serializer. Is it the application, by hanging on to it and just resetting it (in which case reset() should be made public), or is it the SerializerFactory by maintaining an internal pool of serializers, in which case you have to call close() on the serializer. Either one will work with the current implementation, but the jury is still out on which method it should be. Comments are more than welcome. arkin Keith Visco wrote: > > My thoughts.... > > When the depth of the tree drops back to 0 (ie. the root element is > finished printing) The serializer should reinitialize itself. I don't > like to rely on a call to #endDocument, though there is nothing wrong > with forcing a user to do so if necessary. > > I don't think a Serializer needs to be thread safe since that won't make > much sense in the event world of SAX, but I see nothing wrong with > making a serializer reusable. > > --Keith > > 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
