[XML-SIG] (patch) Re: Getting namespace aware parser to work...

Clark C. Evans cce@clarkevans.com
Mon, 19 Mar 2001 07:16:15 -0500 (EST)


This is a nicer patch to saxutils.py to fix the default 
namespace handling.  Please excuse the bad python code... I'm 
still less than 100 lines old... so it may have stupid errors.

---------------------
141a142
>         self._default_context = None
171c172
<             name = name[1]
---
>             self._out.write('<' + name[1])
173,175c174,183
<             name = self._current_context[name[0]] + ":" + name[1]
<         self._out.write('<' + name)
<
---
>             prefix = self._current_context[name[0]]
>             if prefix is None:
>                 if self._default_context is None or
self._default_context != name[0]:
>                     self._out.write('<%s xmlns="%s"' %
(name[1],name[0]) )
>                     self._default_context = name[0]
>                 else:
>                     self._out.write('<' + name[1])
>             else:
>                 self._out.write('<' + prefix  + ":" + name[1])
>
177c185,188
<             self._out.write(' xmlns:%s="%s"' % pair)
---
>             if pair[0] is None:
>                 pass
>             else:
>                 self._out.write(' xmlns:%s="%s"' % pair)
181,182c192,196
<             name = self._current_context[name[0]] + ":" + name[1]
<             self._out.write(' %s="%s"' % (name, escape(value)))
---
>             if name[0] is None:
>                 qname = name[1]
>             else:
>                 qname = self._current_context[name[0]] + ":" + name[1]
>             self._out.write(' %s="%s"' % (qname, escape(value)))
192c206,210
<             qname = self._current_context[name[0]] + ":" + name[1]
---
>             prefix = self._current_context[name[0]]
>             if prefix is None:
>                 qname = name[1]
>             else:
>                 qname = prefix + ":" + name[1]