ddn.data.xml.xpointer
XPointer Framework.
This module implements the XPointer Framework (W3C Recommendation) for addressing fragments of XML documents.
Supported pointer forms:
- Shorthand pointers:
#id— resolves to the first element with a matchingidattribute element()scheme:element(id),element(/1/2/3),element(id/2)— addresses elements by ID and/or child sequence numbersxpointer()scheme:xpointer(XPathExpr)— evaluates an XPath 1.0 expression against the document elementxmlns()scheme:xmlns(prefix=uri)— binds a namespace prefix for use in subsequentxpointer()schemes
Scheme fallback: when multiple scheme parts are present, they are evaluated in order and the first one that resolves to a non-empty result wins.
Remaining limitations:
- The
xpointer()scheme evaluates XPath against the document element, not the document root node - The
element()scheme only matches elements with an unprefixedidattribute; DTD-declared ID-type attributes are not recognized - `^(` and `^)` escaping in scheme data is not supported
- Point and range semantics (
point(),range(),range-to(),string-range()) are not supported and are explicitly out of scope
Reference: https://www.w3.org/TR/xptr-framework/
enum XPointerKind
Types 3
enumXPointerKind
XPointer kind.
SHORTHANDShorthand pointer of the form `#id`.
ELEMENT`element()` scheme: addresses elements by ID or child sequence.
XPOINTER`xpointer()` scheme: evaluates an XPath 1.0 expression.
XMLNS`xmlns()` scheme: binds a namespace prefix for subsequent schemes.
structXPointerPart
A single part of an XPointer (either a scheme or a shorthand).
Fields are used depending on kind:
SHORTHAND:idELEMENT:elementId,elementAbsolute,elementSequenceXPOINTER:xpathXMLNS:xmlnsPrefix,xmlnsUri
Fields
XPointerKind kindstring idstring elementIdbool elementAbsolutesize_t[] elementSequencestring xpathstring xmlnsPrefixstring xmlnsUristructXPointer
Parsed XPointer.
Fields
XPointerPart[] partsPointer parts in order.Methods
XmlNode[] evaluate(XmlDocument doc, Options options = Options.init) @safeEvaluates this pointer against a document.Nested Templates
OptionsEvaluation strictness options.