oilleelssq-wq/moonxslt/xml does not have a README file

    XmlError

    pub suberror XmlError {
    Parse(String, Int, Int)
    }

    Internal parser error carrying the source position.

    Document

    pub struct Document {
    nodes : Array[Node]
    root_id : Int?
    }

    A parsed XML document.

    Document::add_attribute

    fn Document::add_attribute(self : Document, element : Int, name : QName, value : String) -> Int

    Append an attribute node to an element.

    Attribute ids are ordered by declaration and share the document-order key of their element.

    Document::add_comment

    fn Document::add_comment(self : Document, parent : Int, text : String) -> Int

    Append a comment node under parent.

    Document::add_element

    fn Document::add_element(self : Document, parent : Int, name : QName) -> Int

    Append a new element node under parent and return its id.

    Used by the parser and by result-tree construction in the XSLT engine.

    Document::add_processing_instruction

    fn Document::add_processing_instruction(self : Document, parent : Int, target : String, data : String) -> Int

    Append a processing-instruction node under parent.

    Document::add_raw_text

    fn Document::add_raw_text(self : Document, parent : Int, text : String) -> Int

    Append a text node whose content is written without escaping, for disable-output-escaping="yes".

    Document::add_text

    fn Document::add_text(self : Document, parent : Int, text : String) -> Int

    Append a text node under parent.

    Adjacent text nodes are merged, as required by the XPath data model; in that case the existing node id is returned.

    Document::ancestors

    fn Document::ancestors(self : Document, id : Int) -> Array[Int]

    Ancestors of a node, nearest first.

    Document::ancestors_or_self

    fn Document::ancestors_or_self(self : Document, id : Int) -> Array[Int]

    Ancestors of a node, nearest first, including the node itself.

    Document::attribute_by_expanded

    fn Document::attribute_by_expanded(self : Document, element : Int, uri : String, local_part : String) -> Int?

    Look up an attribute by expanded (uri, local_part) name.

    Document::attribute_by_local

    fn Document::attribute_by_local(self : Document, element : Int, local_part : String) -> Int?

    Look up an attribute by local_part name, ignoring the namespace.

    Document::attribute_value

    fn Document::attribute_value(self : Document, element : Int, local_part : String) -> String?

    Look up an attribute value by local_part name.

    Document::attributes

    fn Document::attributes(self : Document, id : Int) -> ArrayView[Int]

    Attribute node ids of an element, in declaration order.

    Document::children

    fn Document::children(self : Document, id : Int) -> ArrayView[Int]

    Child node ids of a document or element node, in document order.

    Document::compare_order

    fn Document::compare_order(self : Document, a : Int, b : Int) -> Int

    Compare two node ids in document order.

    Returns a negative number when a precedes b, zero when they are the same node, and a positive number otherwise.

    Document::declare_namespace

    fn Document::declare_namespace(self : Document, element : Int, prefix : String, uri : String) -> Unit

    Record a namespace declaration on an element.

    Document::descendants

    fn Document::descendants(self : Document, id : Int) -> Array[Int]

    Descendants of a node in document order, excluding the node itself.

    Document::descendants_or_self

    fn Document::descendants_or_self(self : Document, id : Int) -> Array[Int]

    Descendants of a node in document order, including the node itself.

    Document::document_order

    fn Document::document_order(self : Document, id : Int) -> Int

    Document-order key of a node.

    Nodes are numbered in document order, except that attributes reuse the order key of their owning element so that a sort on (order, id) yields element, then its attributes, then its children.

    Document::empty

    fn Document::empty() -> Document

    Create an empty document containing only the document node.

    Document::following

    fn Document::following(self : Document, id : Int) -> Array[Int]

    Nodes following a node in document order, excluding its descendants and all attribute nodes.

    Document::following_siblings

    fn Document::following_siblings(self : Document, id : Int) -> Array[Int]

    Siblings following a node, in document order.

    Document::has_children

    fn Document::has_children(self : Document, id : Int) -> Bool

    Whether the node has children.

    Document::import_subtree

    fn Document::import_subtree(self : Document, parent : Int, source : Document, node : Int) -> Int

    Copy a subtree from another document under parent.

    Names are already resolved in the source document, so the copy keeps the resolved names, the namespace declarations and the text escaping flags. Returns the id of the copied node, or parent for node kinds that cannot be copied (document and attribute nodes).

    Document::index_in_parent

    fn Document::index_in_parent(self : Document, id : Int) -> Int?

    Position of a node among its parent's children, or among its element's attributes for attribute nodes.

    Document::is_attribute

    fn Document::is_attribute(self : Document, id : Int) -> Bool

    Whether a node is an attribute.

    Document::is_comment

    fn Document::is_comment(self : Document, id : Int) -> Bool

    Whether a node is a comment.

    Document::is_document_node

    fn Document::is_document_node(self : Document, id : Int) -> Bool

    Whether a node is the document node.

    Document::is_element

    fn Document::is_element(self : Document, id : Int) -> Bool

    Whether a node is an element.

    Document::is_escaped_text

    fn Document::is_escaped_text(self : Document, id : Int) -> Bool

    Whether the content of a text node is escaped on output.

    Document::is_processing_instruction

    fn Document::is_processing_instruction(self : Document, id : Int) -> Bool

    Whether a node is a processing instruction.

    Document::is_text

    fn Document::is_text(self : Document, id : Int) -> Bool

    Whether a node is a text node.

    Document::is_whitespace_text

    fn Document::is_whitespace_text(self : Document, id : Int) -> Bool

    Whether a text node consists only of XML whitespace.

    Document::kind

    fn Document::kind(self : Document, id : Int) -> NodeKind?

    Kind of the node with the given id.

    None means the id is out of range.

    Document::local_name

    fn Document::local_name(self : Document, id : Int) -> String

    The local_part part of an element or attribute name.

    Document::name

    fn Document::name(self : Document, id : Int) -> QName?

    The expanded name of an element or attribute node.

    Document::namespace_declarations

    fn Document::namespace_declarations(self : Document, id : Int) -> ArrayView[(String, String)]

    Namespace declarations attached to an element, as (prefix, uri) pairs.

    The empty prefix denotes the default namespace.

    Document::namespace_uri

    fn Document::namespace_uri(self : Document, id : Int) -> String

    The namespace URI of an element or attribute name, "" when unqualified.

    Document::node_count

    fn Document::node_count(self : Document) -> Int

    Number of nodes in the arena, including the document node.

    Document::nodes_in_document_order

    fn Document::nodes_in_document_order(self : Document) -> Array[Int]

    All element, text, comment and processing-instruction nodes of the document in document order. Attribute nodes are excluded, because XPath never places them in the following or preceding axis.

    Document::parent

    fn Document::parent(self : Document, id : Int) -> Int?

    Parent id of a node, or None for the document node.

    Document::preceding

    fn Document::preceding(self : Document, id : Int) -> Array[Int]

    Nodes preceding a node in document order, excluding its ancestors.

    Document::preceding_siblings

    fn Document::preceding_siblings(self : Document, id : Int) -> Array[Int]

    Siblings preceding a node, in document order.

    Document::qualified_name

    fn Document::qualified_name(self : Document, id : Int) -> String

    The lexical name of an element or attribute node.

    Document::remove_child

    fn Document::remove_child(self : Document, parent : Int, child : Int) -> Unit

    Remove a child from its parent.

    Document::resolve_prefix

    fn Document::resolve_prefix(self : Document, node : Int, prefix : String) -> String?

    Resolve a namespace prefix for the given node by walking up the tree.

    Returns None for an undeclared prefix.

    Document::root

    fn Document::root(self : Document) -> Int?

    Id of the document element, if the document has one.

    Document::root_of

    fn Document::root_of(self : Document, id : Int) -> Int

    Root of the tree containing a node, which is the document node for parsed documents.

    Document::set_attribute_value

    fn Document::set_attribute_value(self : Document, attribute : Int, value : String) -> Unit

    Change the value of an existing attribute node.

    Document::set_element_name

    fn Document::set_element_name(self : Document, element : Int, prefix : String, local_part : String, uri : String) -> Unit

    Set the resolved name of an element once its namespace scope is known.

    Document::set_root

    fn Document::set_root(self : Document, id : Int) -> Unit

    Mark the document element.

    Document::sort_document_order

    fn Document::sort_document_order(self : Document, ids : Array[Int]) -> Array[Int]

    Sort node ids into document order and drop duplicates.

    Document::text_content

    fn Document::text_content(self : Document, id : Int) -> String

    Concatenated character data of the node and all its descendants, which is the XPath string() of an element.

    Document::to_xml

    fn Document::to_xml(self : Document, indent? : Bool, declaration? : Bool) -> String

    Serialise the document to XML.

    With indent = true the output is pretty printed: element children are put on their own lines, while text-only content stays inline.

    Document::value

    fn Document::value(self : Document, id : Int) -> String

    Character data of a text, comment or processing-instruction node.

    Document::write_node

    fn Document::write_node(self : Document, id : Int, sb : StringBuilder, indent : Bool, depth : Int) -> Unit

    Serialise a single node subtree.

    Node

    type Node

    A single node of the document arena.

    Only name, value and parent are ever reassigned after creation, so the remaining fields are immutable.

    NodeKind

    pub(all) enum NodeKind {
    Document
    Element
    Attribute
    Text
    Comment
    ProcessingInstruction
    }

    The six node kinds of the XPath 1.0 data model.

    Namespace nodes are not materialised: the namespace axis is derived from the declarations stored on element nodes.

    QName

    pub struct QName {
    prefix : String
    local_part : String
    uri : String
    }

    A namespace-aware qualified name.

    uri is the empty string when the name has no namespace.

    QName::expanded

    fn QName::expanded(self : QName) -> String

    The expanded name, used for matching in XPath and XSLT.

    QName::local_part

    fn QName::local_part(self : QName) -> String

    QName::new

    fn QName::new(prefix : String, local_part : String, uri : String) -> QName

    QName::prefix

    fn QName::prefix(self : QName) -> String

    QName::qualified

    fn QName::qualified(self : QName) -> String

    The lexical form of the name, i.e. prefix:local_part or local_part.

    QName::uri

    fn QName::uri(self : QName) -> String

    XmlErrorInfo

    pub(all) struct XmlErrorInfo {
    message : String
    line : Int
    column : Int
    }

    A well-formedness error with the position where it was detected.

    escape_attribute

    fn escape_attribute(text : String) -> String

    Escape an attribute value, including the whitespace characters that a parser would otherwise normalise.

    escape_text

    fn escape_text(text : String) -> String

    Escape character data.

    is_xml_whitespace

    fn is_xml_whitespace(c : Char) -> Bool

    XML whitespace characters.

    parse

    fn parse(text : String) -> Result[Document, XmlErrorInfo]

    Parse an XML document.

    Returns a descriptive error, including the line and column, when the input is not well formed.

    parse_or_raise

    fn parse_or_raise(text : String) -> Document raise XmlError

    Parse an XML document, raising XmlError on malformed input.

    split_qname

    fn split_qname(name : String) -> (String, String)?

    Split a lexical name into (prefix, local_part).

    Returns None when the name contains more than one colon, which XML does not allow.