LxmlEventHandler

class xsdata.formats.dataclass.parsers.handlers.LxmlEventHandler(parser, clazz)[source]

Event handler based on lxml.etree.iterparse api.

Parameters:
  • parser (PushParser) – The parser instance to feed with events

  • clazz (Optional[Type, None]) – The target binding model, auto located if omitted.

parse(source)[source]

Parse an XML document from a system identifier or an InputSource or directly from a lxml Element or Tree.

When Source is a lxml Element or Tree the handler will switch to the lxml.etree.iterwalk api.

When source is a system identifier or an InputSource the parser will ignore comments and recover from errors.

When config process_xinclude is enabled the handler will parse the whole document and then walk down the element tree.

Return type:

Any

process_context(context)[source]

Iterate context and push the events to main parser.

Return type:

Any

merge_parent_namespaces(ns_map)

Merge and return the given prefix-URI map with the parent node.

Register new prefixes with the parser.

Parameters:

ns_map (Dict) – Namespace prefix-URI map

Return type:

Dict