Msg#: 3766232 posted 4:40 pm on Oct 15, 2008 (gmt 0)
I'm working on a Java application which transforms a DOMSource object (javax.xml.transform.dom.DOMSource) to a StreamResult object (javax.xml.transform.stream.StreamResult) which is then written to a file. This seems to output empty elements using the short notation:
Unfortunately, a 3rd party that I'm working with needs the XML to use the long format with a closing tag:
This question may be somewhat Java specific, but does anyone know of a way to configure the transformer to output the long format?
Msg#: 3766232 posted 9:00 pm on Oct 15, 2008 (gmt 0)
The closed format is the "proper" format for a node with no children. But I know what you mean - some HTML tags (like <script> and <textarea>) mustn't be closed like that, or Bad Things May Happen.
I have that problem with a certain .NET XSLT parser. It has problems with all empty nodes - and it totally barfs on "<textarea></textarea>". There is no config option available to fix it, so we've had to put spaces in all our nodes to keep them from self-closing... it's a nasty solution that has caused several other problems further up the stack.
You might also try:
<node>&NULLENTITY;</node> where NULLENTITY is declared to be NULL (or, an empty string) in the DTD, like this: <!ENTITY NULLENTITY "">
Not being a Javaist I don't know if any of the above will work
Msg#: 3766232 posted 9:14 pm on Oct 15, 2008 (gmt 0)
Thanks. In our case, the output is an RSS feed. But the company that ingests it must not be using a standard parser. Thanks for the suggestions. If I can't find a way to force the end tag to be generated, then perhaps an empty string will work.