Skip to main content

Crate quarb_xml

Crate quarb_xml 

Source
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-name and :::ns-prefix metadata allow prefix-agnostic filtering (//*[:::local-name = "title"]). The document root is unnamed; the document element is its single child.
  • The traits are few: the root wears document, every element element, and a table element tabula as well. XML has no universal structural vocabulary beyond that; the leaf and container distinctions are core metadata (:is-leaf, :n-children).
  • Attributes are properties: ::pages, ::href. The default projection (::) and ::text are the element’s text content; :::tag, :::id, :::local-name, :::ns-prefix, :::n-attrs, and any :::attr expose metadata; :::texts is the list of the element’s immediate text runs (XPath’s text()).
  • An attribute holding an ID reference resolves: ::ref--> follows a bare IDREF value (book="b1") or a fragment (href="#b1") to the element with that id or xml:id.
  • Input is UTF-8 text; an encoding declaration 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.
XmlStream
An XML document with one repeated child streamed (hash (d) of the columnar round, 2026-11-06): the document element’s children — <page> under <mediawiki>, <entry> under <dictionary> — as byte spans found by one pass of the reader, each parsed into its own arbor when a step reaches it, wrapped in the document element’s own start tag so its prefixes resolve as in the whole parse; the document element itself, its attributes and the prologue parsed whole as the PREFIX document with the children left out. The node ids pack the child’s index above its arbor’s node; the prefix’s nodes keep their own ids below.

Enums§

XmlError
An error building an XmlAdapter from document text.

Functions§

declared_encoding
The encoding an XML document declares in its prologue (<?xml version="1.0" encoding="windows-1251"?>), reported for the engine’s source boundary. The adapter decodes nothing: the boundary applies the declaration after ?encoding= and a byte-order mark have had their say. The prologue is scanned as ASCII-compatible bytes, as the XML recommendation’s appendix F reads it; a document whose first bytes are not <?xml declares nothing.