Minidom empty script element bug

Derek Basch dbasch at yahoo.com
Wed Mar 16 11:56:54 EST 2005


Cross post from XML-SIG:

--- Walter Dörwald <walter at livinglogic.de> wrote:
> 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"/>
>
> Bye,
>    Walter Dörwald

Wow! XIST is very elegant. Perfectly designed for what it is supposed
to do.

"XIST is an extensible HTML/XML generator written in Python."

I guess there isn't much point in "fixing" the pyXML XHTMLPrinter when
something as cool as XIST exists (pun intended).

Kid also seems really neat. I like the TAL like features. However, it
seems less mature than XIST.

There seems to be lots of functionality crossover between the two but
it is good that there is enough demand for XML output functionality in
python to support two distinct modules.

Thanks Everyone!,
Derek Basch




More information about the Python-list mailing list