XmlEventDecoder constructor
Creates a new XmlEventDecoder.
If validateDocument is true, the parser validates that the root elements
of the input follow the requirements of an XML document. This means the
document consists of an optional declaration, an optional doctype, and a
single root element. When false (default), fragments or continuous element
streams are accepted without error.
If validateNamespace is true, the parser validates the declaration and
use of namespaces and throws an XmlNamespaceException if an undeclared
namespace prefix is used or a duplicate namespace declaration occurs.
If validateNesting is true, the parser validates the nesting of tags and
throws an XmlTagException if there is a mismatch or tags are not closed.
In case of an error, iteration can be resumed with the next event.
If validateAttributes is true, the parser validates that attributes on
elements and declarations are unique and throws an XmlAttributeException
if a duplicate attribute is encountered.
Furthermore, the following annotations can be enabled if needed:
- If
withLocationistrue, each event is annotated with the starting and stopping position (exclusive) of the event in the input buffer. - If
withNamespaceistrue, the namespace of the element is resolved and added to the event. - If
withParentistrue, each event is annotated with its logical parent event.
Implementation
new({
XmlEntityMapping? entityMapping,
this.validateDocument = false,
this.validateNamespace = false,
this.validateNesting = false,
this.validateAttributes = false,
this.withLocation = false,
this.withNamespace = false,
this.withParent = false,
}) : entityMapping = entityMapping ?? defaultEntityMapping;