[XML-SIG] Re: Minidom empty script element bug

Walter Dörwald walter at livinglogic.de
Wed Mar 16 08:53:31 CET 2005

Martin v. Löwis sagte:
> Derek Basch wrote:
> >[...]
>> How do I get minidom to NOT render an empty script element? Should I submit a bug report?
> That said, I think there is a simple solution: add an empty Text node to the script element:
> script_node_0.appendChild(doc.createText(u""))
> [Disclaimer: this is untested; from reading the source, I think it  should work]

If this doesn't work, you might want to try XIST (http://www.livinglogic.de/Python/xist)
instead of minidom. XIST knows that the script element is not EMPTY, and when the
output is in HTML compatible XML an end tag will be produced:

>> from ll.xist.ns import html
>>> print html.script(type="text/javascript", src="../test.js").asBytes(xhtml=1)
<script src="../test.js" type="text/javascript"></script>

Using pure XML mode gives:

>>> print html.script(type="text/javascript", src="../test.js").asBytes(xhtml=2)
<script src="../test.js" type="text/javascript"/>

   Walter Dörwald

More information about the XML-SIG mailing list