[XML-SIG] Namespace Stripper Filter

Lars Marius Garshol larsga@garshol.priv.no
20 Mar 2001 09:11:56 +0100


* Clark C. Evans
|
|     def startElementNS(self, name, qname, attrs):
|         """Ignores elements and strips attributes of nmsp"""
|         if name[0] != self.nmsp:
|             #
|             # Warning: For efficiency this dives into the
|             #          underlying representation of AttributesNSImpl
|             #          and deletes attributes to be stripped.
|             #
|             #  _attrs should be of the form {(ns_uri, lname): value, ...}.
|             #  _qnames of the form {(ns_uri, lname): qname, ...}."""
|             #
|             for (ns_uri,lname) in attrs._attrs.keys():
|                 if self.nmsp == ns_uri: del attrs._attrs[(ns_uri,lname)]
|             self._cont_handler.startElementNS(name,qname,attrs)
|         else:
|             self.depth = self.depth + 1

This isn't really a good idea, since there is no guarantee that you
will in fact get AttributesNSImpl instances. The only thing that is
guaranteed is that the objects you get will follow that interface.

It is very likely that many SAX drivers, such as the Jython SAX
driver, will not use this class, but reimplement the interface in a
class specific to themselves.

Otherwise it looked fine to me.

--Lars M.