LxmlSaxHandler

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

Sax content handler based on lxml.etree.XMLParser api.

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

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

parse(source)[source]

Parse an XML document from a system identifier or an InputSource.

The xml parser will ignore comments, recover from errors and clean duplicate namespace prefixes.

Parameters

source (Any) –

Return type

Any

close()

Close document notification receiver.

The receiver will flush any previous active element and return the first item in the objects stack.

Return type

Any

data(data)

Data notification receiver.

The receiver will append the given data content in the current data frame either in the text position 0 or in the tail position 1 whether the element has ended or not.

Parameters

data (str) – Text or tail content

end(qname)

End element notification receiver.

The receiver will flush any previous active element and set the next element to be flushed.

Parameters

qname (str) – Qualified name

flush()

Flush element notification receiver.

The receiver will check if there is an active element present, collect and join the data frames for text/tail content and notify the main parser to finish the binding process for the element.

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

start(qname, attrs, ns_map)

Start element notification receiver.

The receiver will flush any previous active element, append a new data frame to collect data content for the next active element and notify the main parser to prepare for next binding instruction.

Parameters
  • qname (str) – Qualified name

  • attrs (Dict) – Attribute key-value map

  • ns_map (Dict) – Namespace prefix-URI map