xmlproc now supports XML namespaces through the addition of the xml.parsers.xmlproc.namespace module. In this module there is a NamespaceFilter class which is implemented as a parser filter. This means that it is registered with the parser as an application, and that your application then registers with the filter as the real application.
The parser will then parse as normal and send parse events to the NamespaceFilter, which will do namespace transformations and pass the events on to your application.
This is an example of how namespace processing can be set up:
from xml.parsers.xmlproc import xmlproc,namespace class MyApplication(xmlproc.Application): pass # Add some useful stuff here p=xmlproc.XMLProcessor() nsf=namespace.NamespaceFilter(p) nsf.set_application(MyApplication()) # register error handlers and all other handlers with the parser, # not the filter p.set_application(nsf) p.parse_resource("foo.xml")
MyApplication will now receive parse events where all prefixed names have been processed into names consisting of the namespace URI, followed by a space and then the local part of the name. If this isn't clear to you, try using the -n option to xvcmd.py and xpcmd.py and -o x to see what the filter does.
This is the complete NamespaceFilter interface: