Details
-
Type:
Wish
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Labels:None
-
Number of attachments :
Description
If I write anything before calling XMLStreamWriter.writeStartDocument, Woodstox complains:
javax.xml.stream.XMLStreamException: Trying to output non-whitespace characters outside main element tree (in prolog or epilog)
This prevents me from using Woodstox to output XML fragments (i.e. small pieces of XML without a prolog), e.g. in custom JSP tags.
Interesting. I will need to have a look at the problem. A very quick work-around (in case you need to make it work before fixes, or fow older version) is to disable structural checks (there's a property in WstxOutputProperties, or so), which are on by default. Disabling these checks should prevent the particular exception.
I was wondering if it would be necessary to implementing something similar to what input side does (allow 3 modes: standard tree, fragment, or multi-doc ["forest"]) on output side as well, but thought I'll wait until someone needs such a feature. Sounds like you do.
Anyway, I will need to have a look at sources: it may be that it's not so much related to writeStartDocument(), but to missing writeStartElement() call: or put another way, writer's preference to write well-formed output and prevent non-whitespace stuff outside of main document tree. If so, "fragment mode" is probably needed.