> Why don't just use the XMLWriter as it is, there is a write(Element)
method
> in it...

The issue is that the complete DOM model of the XML file I am writing can't
be loaded into memory at once. Or, put differently, I need to be able to
print as I read.

XmlWriter of course always prints complete trees, which results in the
following output if one attempts to print a document element by element
without keeping all elements in memory:

<root xmlns:xsi="...">
    <element>...</element>
</root>
<root xmlns:xsi="...">
    <element>...</element>
</root>
<root xmlns:xsi="...">
    <element>...</element>
</root>


As a workaround one could manually print the root begin and end tags.
Unfortunately this strategy interferes with the proper placing of namespace
prefixes as well as the indentation:

<root>
<element xmlns:xsi="...">...</element>
<element xmlns:xsi="...">...</element>
<element xmlns:xsi="...">...</element>
</root>


This is what the output should look like:

<root xmlns:xsi="...">
    <element>...</element>
    <element>...</element>
    <element>...</element>
</root>


Perhaps the proper solution would be to write the tree of each element to a
SAX content handler. Does anyone know where to find a pretty-printing SAX
handler? Seems like a rather basic thing, but I couldn't find anything...


--
Eric Jain





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to