Anyone have a clue if there is a way to use the XMLStreamWriter to get:
<elem attr="1"/>
instead of:
<elem attr="1"></elem>
for elements with attributes but no content?
If not, this seems VERY BAD.
Here is some code:
String xml = "<test attr='foo'><check/></test>";
ByteArrayInputStream bis = new
ByteArrayInputStream(xml.getBytes());
XMLStreamReader reader =
XMLInputFactory.newInstance().createXMLStreamReader(bis);
OMXMLParserWrapper builder =
OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getSOAP11Factory(),
reader);
XMLStreamWriter writer =
XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
builder.getDocumentElement().serialize(writer);
NOTE - to get this working I needed to update StreamingOMSerializer:137
with:
writer.writeStartElement(reader.getLocalName());
This code outputs:
<test attr="foo"><check xmlns=""></check></test>
This doesn't seem correct. It should, I think, output the <check/>
element as it is in the original XML, and it certainly shouldn't be
adding the xmlns="" attribute. Am I missing something?
Thanks,
--Glen