XmlExtensionMap class
Stores unknown XML attributes and child elements for round-trip preservation.
This "Shadow Model" ensures that when reading a DOCX file, any XML attributes or elements that aren't formally modeled are preserved and written back exactly as they were found.
Example usage:
// When parsing an anchor element, extract unknown attributes
final extensions = XmlExtensionMap.extractFromElement(
anchorElement,
knownAttributes: {'distT', 'distB', 'simplePos'},
);
// Later, when writing back
extensions.writeAttributesTo(builder);
Constructors
Properties
-
attributes
→ Map<
String, String> -
Unknown attributes: qualified name -> value
final
-
childElements
→ List<
String> -
Unknown child elements as raw XML strings
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Returns true if there's no extension data to preserve.
no setter
- isNotEmpty → bool
-
Returns true if there is extension data to preserve.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
merge(
XmlExtensionMap other) → XmlExtensionMap -
Merges this extension map with another, preferring values from
other. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
writeAttributesTo(
XmlBuilder builder) → void -
Writes the unknown attributes to an
XmlBuilder. -
writeChildrenTo(
XmlBuilder builder) → void -
Writes the unknown child elements to an
XmlBuilder.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
extractFromChildren(
XmlElement element, {required Set< String> knownChildren}) → XmlExtensionMap - Extract unknown child elements from an element, given a set of known element names.
-
extractFromElement(
XmlElement element, {required Set< String> knownAttributes}) → XmlExtensionMap - Extract unknown attributes from an element, given a set of known attribute names.
-
extractFull(
XmlElement element, {required Set< String> knownAttributes, required Set<String> knownChildren}) → XmlExtensionMap - Extract both unknown attributes and children.