xsdata.codegen.parsers package

Submodules

Module contents

class xsdata.codegen.parsers.SchemaParser(config=<factory>, context=<factory>, handler=<class 'xsdata.formats.dataclass.parsers.handlers.lxml.LxmlEventHandler'>, index=<factory>, indices=<factory>, location=None, target_namespace=None, default_attributes=None, default_open_content=None)[source]

Bases: xsdata.formats.dataclass.parsers.xml.XmlParser

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.

Parameters
index: int
indices: List[int]
location: Optional[str] = None
element_form: Optional[xsdata.models.enums.FormType] = None
attribute_form: Optional[xsdata.models.enums.FormType] = None
target_namespace: Optional[str] = None
default_attributes: Optional[str] = None
default_open_content: Optional[xsdata.models.xsd.DefaultOpenContent] = None
start(clazz, queue, objects, qname, attrs, ns_map)[source]

Queue the next xml node for parsing.

Emit a start event with the current element qualified name and attributes.

Parameters
end(queue, objects, qname, text, tail)[source]

Override parent method to set element index and namespaces map.

Parameters
Return type

Any

start_schema(attrs)[source]

Collect the schema’s default form for attributes and elements for later usage.

Parameters

attrs (Dict) –

set_schema_forms(obj)[source]

Set the default form type for elements and attributes.

Global elements and attributes are by default qualified.

Parameters

obj (Schema) –

set_schema_namespaces(obj)[source]

Set the given schema’s target namespace and add the default namespaces if the are missing xsi, xlink, xml, xs.

Parameters

obj (Schema) –

static set_namespace_map(obj, ns_map)[source]

Add common namespaces like xml, xsi, xlink if they are missing.

Parameters
static set_index(obj, index)[source]
Parameters
  • obj (Any) –

  • index (int) –

static add_default_imports(obj)[source]

Add missing imports to the standard schemas if the namespace is declared and.

Parameters

obj (Schema) –

resolve_schemas_locations(obj)[source]

Resolve the locations of the schema overrides, redefines, includes and imports relatively to the schema location.

Parameters

obj (Schema) –

resolve_path(location)[source]

Resolve the given location string relatively the schema location path.

Parameters

location (Optional[str]) –

Return type

Optional[str]

resolve_local_path(location, namespace)[source]

Resolve the given namespace to one of the local standard schemas or fallback to the external file path.

Parameters
Return type

Optional[str]

end_attribute(obj)[source]

Assign the schema’s default form for attributes if the given attribute form is None.

Parameters

obj (~T) –

end_complex_type(obj)[source]

Prepend an attribute group reference when default attributes apply.

Parameters

obj (~T) –

end_default_open_content(obj)[source]

Set the instance default open content to be used later as a property for all extensions and restrictions.

Parameters

obj (~T) –

end_element(obj)[source]

Assign the schema’s default form for elements if the given element form is None.

Parameters

obj (~T) –

end_extension(obj)[source]

Set the open content if any to the given extension.

Parameters

obj (~T) –

classmethod end_open_content(obj)[source]

Adjust the index to trick later processors into putting attributes derived from this open content last in classes.

Parameters

obj (~T) –

end_restriction(obj)[source]

Set the open content if any to the given restriction.

Parameters

obj (~T) –

end_schema(obj)[source]

Normalize various properties for the schema and it’s children.

Parameters

obj (~T) –

class xsdata.codegen.parsers.DefinitionsParser(config=<factory>, context=<factory>, handler=<class 'xsdata.formats.dataclass.parsers.handlers.lxml.LxmlEventHandler'>, index=<factory>, indices=<factory>, location=None, target_namespace=None, default_attributes=None, default_open_content=None)[source]

Bases: xsdata.codegen.parsers.schema.SchemaParser

A simple parser to convert a wsdl to an easy to handle data structure based on dataclasses.

Parameters
end_definitions(obj)[source]

Normalize various properties for the schema and it’s children.

Parameters

obj (~T) –

index: int
indices: List[int]