xsdata.parser module¶
-
class
xsdata.parser.
SchemaParser
(context, elements=<factory>)[source]¶ Bases:
object
A simple parser to convert an xsd schema to an easy to handle data structure based on dataclasses.
The parser is a dummy as possible but it will try to normalize certain things like apply parent properties to children.
-
context
: etree.iterparse = None¶
-
elements
: List[BaseModel] = None¶
-
element_form
: Optional[xsdata.models.enums.FormType] = None¶
-
attribute_form
: Optional[xsdata.models.enums.FormType] = None¶
-
classmethod
create
(source)[source]¶ A shortcut class method to initialize the parser, parse the given source and return the generated Schema instance.
- Return type
-
parse
()[source]¶ Main parse procedure which depends heavily on binding data classes that have all the necessary attributes to match all the possible xsd elements and attributes.
Elements are initialized on the start event of the parser and assigned to the parent element on the end event. The procedure all includes start/end hooks for each element type.
Elements with no attributes and text are ignored.
- Return type
-
start_schema
(schema, *args)[source]¶ Collect the schema’s default form for attributes and elements for later usage.
-
start_element
(element, *args)[source]¶ Assign the schema’s default form for elements if the given element form is None.
-
start_attribute
(attribute, *args)[source]¶ Assign the schema’s default form for attributes if the given attribute form is None.
-