[XML-SIG] Utility functions (was: XBEL DTD as a meta-dtd)

Andrew M. Kuchling akuchlin@cnri.reston.va.us
Mon, 21 Sep 1998 18:08:18 -0400 (EDT)

Lars Marius Garshol writes:
>def escape(str):
>    return string.replace(string.replace(str,'&',"&amp;"),"<","&lt;")

	According to section 2.4 of the spec, > also needs to be
escaped as &gt; when it's preceded by ]] ; ]]> needs to be ]]&gt;.
It's probably simplest to always escape > as &gt;, even when it's not

>Here is my XMLWriter (note that it is written for data-oriented
>documents, not document-like ones):

	An interesting class.  What do people think: should it be
added somewhere?  One could obtain similar results by creating a DOM
tree and then linearising it, but that's also more complicated to
learn, so I don't think the XMLWriter class would be completely
redundant.  On the other hand, perhaps it should be layered on top of
DOM, and if it turns out that most XML users know the DOM API anyway,
then XMLWriter really is redundant after all.

A.M. Kuchling			http://starship.skyport.net/crew/amk/
You played me well, mortal. But I have played me for time out of mind. And I
do Robin Goodfellow better than anyone.
    -- Robin Goodfellow, in SANDMAN #19: "A Midsummer Night's Dream"