I do not see an option within javax.xml.stream.XMLEventWriter
or javax.xml.stream.XMLOutputFactory
to set either up in a way so that empty elements are written (instead of explicit start and end element pairs).
I see that Woodstox has a property to do this, but it is not standardized.
Am I missing any obvious way to do this?
writer.writeEmptyElement("some_element");
writer.writeAttribute("some_attribute", "some_value");
Setting property so that empty tags are generated like <x/>
works with WoodStox APIs:
WstxOutputFactory factory = new WstxOutputFactory();
factory.setProperty(WstxOutputFactory.P_AUTOMATIC_EMPTY_ELEMENTS, true);
I wanted indentation in XML tags. the setIndentation method is working with neither javax.xml.stream.XMLOutputFactory nor org.codehaus.stax2.XMLOutputFactory2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With