Reputation: 59
I'm currently using XMLStreamWriter to parse together an XML document. The only parameters that I'm allowed to pass in are "encoding" and "version", but I would like to have "standalone=no" in the declaration, as well. Here's what my output currently looks like:
<?xml version='1.0' encoding='UTF-8'?>
How can I make something like this?
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
Upvotes: 1
Views: 2279
Reputation: 163458
XmlStreamWriter
is an interface: it has more than one implementation!
If you install Saxon (any edition), you can create a Serializer using any of the serialization parameters defined in XSLT (for example standalone=yes), and then you can get an XmlStreamWriter
that writes to this Serializer
using Serializer.getXmlStreamWriter()
:
Processor p = new Processor(false);
Serializer s = p.newSerializer(System.out);
s.setOutputProperty(Property.STANDALONE, "no");
XmlStreamWriter writer = s.getXmlStreamWriter();
Upvotes: 1