generateDS generates Python data structures (for example, class definitions) from an XML Schema document. These data structures represent the elements in an XML document described by the XML Schema.
generateDS is also able to generate parsers that load an XML document in the data structures.
In addition, a separate file containing subclasses (stubs) is optionally generated. The user can add methods to the subclasses in order to process the contents of an XML document.
The generated Python code contains:
· A class definition for each element defined in the XML Schema document.
· A main and driver function that can be used to test the generated code.
· A parser that will read an XML document which satisfies the XML Schema from which the parser was generated. The parser creates and populates a tree structure of instances of the generated Python classes.
· Methods in each class to export the instance back out to XML (method export) and to export the instance to a literal representing the Python data structure (method exportLiteral).
The generated classes contain the following:
· A constructor method (__init__), with member variable initializers.
· Methods with names 'getX' and 'setX' for each member variable 'X' or, if the member variable is defined with maxOccurs="unbounded", methods with names 'getX', 'setX', 'addX', and 'insertX'.
· A "build" method that can be used to populate an instance of the class from a node in a minidom tree.
· An "export" method that will write the instance (and any nested sub-instances) to a file object as XML text.
· An "exportLiteral" method that will write the instance (and any nested sub-instances) to a file object as Python literals (text).
What's New in This Release: [ read full changelog ]
· Added support for exporting to an Lxml element tree.The element
· tree can then be serialized to XML, e.g. using Lxml
· etree.tostring().This innovation is by Logan Owen, who also did
· most of the work on it (but I helped some, too).Note that this
· work is not yet complete; it's still "work in progress"; but it
· looks very promising.
· Added --export command line option.This enables the user to
· selectively generate export methods for any or all of normal
· export, export to etree (lxml element tree), or export to literal
· python code.This will enable users to reduce bulk in their
· generated files when any or all of these are not needed.The
· default is "write literal", i.e. the normal export methods that we
· are used to.Use the --help command line option or read the doc
· for a description of this option.
· Fixed a bug that occurs when a schema has an attributeGroup
· referenced with a name that includes a namespace prefix but the
· attributeGroup is defined with a name that does *not* have the
· namespace pr...