[XML-SIG] XBEL DTD as a meta-dtd

Andrew M. Kuchling akuchlin@cnri.reston.va.us
Wed, 16 Sep 1998 13:55:37 -0400 (EDT)

Walter Underwood writes:
>Always, always entify strings as you generate XML. If you slip
>in an unescaped special character, you can lose the a whole
>file worth of data by making it un-parseable (or make someone 
>manually edit it to get it back).

	That reminds me of something: quite a lot of XML-related code
will need to entify code, so there should really be a utility function
available to do this.  Other generally useful functions may become
apparent, too, so I propose an xml.util module.  For now, it'll only
have 1 function:

def escape(string, entity_dict = {}):
    Escapes &, ", and ' in string.  If entity_dict is specified, it
must be a dictionary mapping strings to their entity replacements.
For example, passing {'\234': 'ê'} would cause the 8-bit
character chr(234) to be replaced with ê.

Thoughts?  Should there be a way to specific a character range which
would be escaped numerically, as * or whatever?

A.M. Kuchling			http://starship.skyport.net/crew/amk/
I was honestly very nervous of Constance Wheatcroft. And I wasn't the only
one. Her entire family was afraid of her. Dogs were afraid of her. Bindweed in
the hedge would wither as she passed; birds would forget their nesting
instincts and fly back to north Africa at the sound of her hideous cries.
    -- Tom Baker, in his autobiography