SAX: Help on processing qualified attribute values

Uche Ogbuji uche.ogbuji at
Wed Mar 23 02:10:29 CET 2005

On Thu, 2005-03-10 at 15:22 +0100, Markus Doering wrote:
> Hey,
> I am trying to process XML schema documents using namespace aware SAX 
> handlers. Currently I am using the default python 2.3 parser:
> parser = xml.sax.make_parser()
> parser.setFeature(xml.sax.handler.feature_namespaces, 1)
> At some point I need to parse xml attributes which contain namespace 
> prefixes as their value. For example:
> <xs:element name="hello" type ="xs:string"/>
> The default SAX parser does a good job on dealing with qualified names 
> as xml tags, but is there a way I can access the internal sax mapping 
> between prefixes and full namespaces to be able to parse "qualified 
> attribute values"? A simple private dictionary prefix2namespace would be 
> sufficient.

Just for others, this was answered here:

I also provide a useful mix-in class for this purpose in Amara's

In the latter link see class namespace_mixin, which you should be
able to copy to your code if you don't want to install Amara).

Uche Ogbuji                                    Fourthought, Inc.
Use CSS to display XML, part 2 -
Introducing the Amara XML Toolkit -
Gems from the Mines: 2002 to 2003 -
Be humble, not imperial (in design) -
Querying WordNet as XML -
Packaging XSLT lookup tables as EXSLT functions -

More information about the Python-list mailing list