Expand description
XML adapter for Quarb.
Maps a well-formed XML document onto the arbor model, parsing
with quick-xml. Unlike the HTML adapter, parsing is strict:
mismatched or unclosed tags, duplicate attributes, and unknown
entity references are errors.
- Elements are the nodes; text, CDATA, comments, processing instructions, and the doctype are not navigated (text is exposed as a projection instead).
- A node’s name is its tag exactly as written, including any
namespace prefix (
dc:title). Prefixes are not resolved to URIs. Since:is not a bare-name character in Quarb, a prefixed name is navigated with a quoted segment (//'dc:title');;;;local-nameand;;;ns-prefixmetadata allow prefix-agnostic filtering (//*[;;;local-name = "title"]). The document root is unnamed; the document element is its single child. - Nodes have no traits: XML has no universal structural
vocabulary, and leaf/container distinctions are already
available as core metadata (
:::is-leaf,:::n-children). - Attributes are properties:
::pages,::href. The default projection (::) and::textare the element’s text content;;;;tag,;;;id,;;;local-name,;;;ns-prefix,;;;n-attrs, and any;;;attrexpose metadata. - An attribute holding an ID reference resolves:
::ref~>follows a bare IDREF value (book="b1") or a fragment (href="#b1") to the element with thatidorxml:id. - Input is UTF-8 text; an
encodingdeclaration in the XML prologue is ignored. Only the five predefined entities and numeric character references are resolved.
Structs§
- XmlAdapter
- A Quarb adapter over a parsed XML document.
Enums§
- XmlError
- An error building an
XmlAdapterfrom document text.