LxmlSaxHandler

class xsdata.formats.dataclass.parsers.handlers.LxmlSaxHandler(parser, clazz, queue=<factory>, objects=<factory>)[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. If None the parser will auto locate it from the active xml context instance

  • queue (List) – The XmlNode queue

  • objects (List) – The list of intermediate parsed objects, eg [(qname, object)]

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

start(qname, attrs, ns_map)[source]

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

end(qname)[source]

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

close()[source]

Close document notification receiver.

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

Return type

Any

flush()[source]

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.

data(data)[source]

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