Forum Moderators: open
<myelement />
Unfortunately, a 3rd party that I'm working with needs the XML to use the long format with a closing tag:
<myelement></myelement>
This question may be somewhat Java specific, but does anyone know of a way to configure the transformer to output the long format?
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.
<node> </node>
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
s = s.replaceAll("<([^\\s]*)([^>]*)/>", "<$1$2></$1>");
That regex turned this:
<media:thumbnail height="100" url="http://example.com/a.jpg" width="133"/>
into this:
<media:thumbnail height="100" url="http://example.com/a.jpg" width="133"><//media:keywords>>
Close, but not quite. Any suggestions?
<media:thumbnail height="100" url="http://example.com/a.jpg" width="133"><//media:keywords>>
OK that's just weird. where did "/media:keywords>" come from? it's not in the matched string; in that spot (highlighted red above) should be "media:thumbnail".
Is something amiss with the Java replaceAll() method?