Python and XML Schema

Dennis Benzinger Dennis.Benzinger at gmx.net
Wed Jan 25 20:27:46 CET 2006


Trond wrote:
> I have a need to, given a XML document with XML Schema defined, to get the 
> type of each element in the XML file based on the XML Schema URI given. IE, 
> the <title> element is of simple datatype string. Is there any existing 
> Python libraries were I can parse the XML file, and for a given node ask for 
> the datatype (which should be taken from XML Schema?)
> [...]

Take a look at lxml. It's a pythonic binding for libxml2 and libxslt.
libxml2 <http://xmlsoft.org/> implements XML Schema Part 2: Datatypes 
and partially XML Schema Part 1: Structures.
I don't know how complete the structures implementation is and if it can 
already do what you want. So you might ask the libxml2 guys how to do 
what you want with libxml2 and then use lxml to do it in Python.

Bye,
Dennis



More information about the Python-list mailing list