Expand description
The node model: immutable XML trees stored in an arena, one per document.
A Document holds its nodes in document order: the document node first, then each
element followed by its attributes and then by its children. The index of a node in the
arena is therefore its position in document order, which makes document order a
comparison of two integers and every axis a walk over neighbouring records. Nodes of
different documents are ordered by the documents’ creation order.
Trees are built with a TreeBuilder (the XSLT layer builds its temporary trees with
it) or parsed from XML text with Document::parse, which keeps every text node,
whitespace-only ones included, as Saxon does with -strip:none, and the namespace
prefixes as written in the source (they appear in fn:name). Parsing reads the text
twice with the streaming reader of einvoice-xml, which builds no tree of its own:
once to check it and count its nodes, then to fill an arena of exactly that size.
A built tree may have no document node: a parentless element, attribute, text node,
comment or processing instruction (TreeBuilder::parentless), as the XSLT layer
constructs them in a sequence (the root of its tree is the node itself). The elements
of a built tree have the namespace nodes they were given
(TreeBuilder::start_element_with_namespaces, TreeBuilder::add_namespace), and
those of their ancestors in the tree; the elements of a parsed document have those
declared on them and on their ancestors (Node::namespaces_in_scope). There are no
type annotations: every element and attribute is untyped, so its typed value is
xs:untypedAtomic.
A parsed document may be nested at most DEFAULT_MAX_DEPTH elements deep, or the
maximum given to Document::parse_with_max_depth: beyond it the parse fails with
LimitExceeded::Depth, so that what walks the tree recursively (the template rules of
a stylesheet) has a bounded depth. Parsing, building and walking a tree use no
recursion.
Structs§
- Axis
- The nodes on an axis from a node, in axis order.
- Document
- An immutable XML tree.
- Document
Cache - Documents that
fn:documentloads, parsed once and given to every transformation that loads them again: the code lists a stylesheet reads, the same text under the same URI for each document it validates. - Document
Error - A problem building or parsing a tree.
- Node
- A node: a document and the position of the node in it.
- Tree
Builder - Builds a
Documentfrom events, in document order.
Enums§
- Node
Axis - The axes, in the sense of XPath 2.0 section 3.2.1.1, that the evaluator walks.
descendantis not in the supported XPath subset but is used internally for//name. - Node
Kind - The kind of a node.
- Tree
View - The kind of tree Saxon-HE 12.10 holds for a document, which decides what
id()finds and the form ofgenerate-id().
Functions§
- file_
uri - The
file:URI that Saxon-HE gives a document read from a file: Java’sFile.toURI().toString()of the absolute path. ASCII characters outside the URI path syntax, Unicode space separators and control characters are percent-encoded (UTF-8, upper-case hex); other non-ASCII characters are kept. On Windows,C:\a\bbecomesfile:/C:/a/b.