I use XML streaming when sending results while result are still being
computed. This computation takes some time and can produce lot of
results, but as soon as few results are available, I start streaming
them to the client, and client can then show it in the UI. Both client
and server use XOM. Server simply sends root element and then element
(with mixed content) for each result. Client uses own NodeFactory
subclass to parse and "report" partial results to the upper layer. It
works very well on both sides. Server doesn't need to keep results in
the memory, and for client it isn't all-or-nothing.
As for API, simple writeXMLDeclaration, writeStartTag/writeEndTag (for
root element), write(Element) and flush() worked fine for me.
I had bigger problems with NodeFactory which has only
startMakingElement(String name, String namespace) -- at this point,
attributes are not yet known, and finishMakingElement(Element element)
-- at this point, entire element content is built. My code needed to
react to attributes in root element, but at no point do you get element
with attributes only, without building entire element content.
-Peter
Post by Ian PhillipsHaven't really given this much thought, but off the top of my head?
Post by Elliotte Rusty HaroldI never really planned for streaming serialization because I didn't
think it was very useful. However people seem to keep asking for it,
so maybe it's time to think about this.
serializer.startDocument("rootElement name")
for (int i = 0; i < 1000000000; ++i) {
serializer.write(createNodeWithRandomContent());
}
serializer.endDocument()
?
Or maybe with something that has an efficient (== small) in memory representation but an inefficient (== defined by an external standard) XML representation?
I'm not sure, but I can think of examples where it would be useful.
Also, perhaps, writing out the contents of a DB (embedded or otherwise) to disk in XML format - what happens if the DB is fairly large?
Cheers,
Ian.
#ifndef __COMMON_SENSE__ | Ian Phillips
#include <std_disclaimer> | ianp at ianp.org
#endif | http://ianp.org/
_______________________________________________
XOM-interest mailing list
XOM-interest at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest