Python and XML Schema

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Trond

    #1

    Python and XML Schema

    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?)

    Trond



  • Dennis Benzinger

    #2
    Re: Python and XML Schema

    Trond wrote:[color=blue]
    > 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?)
    > [...][/color]

    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

    Comment

    Working...