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

    EvaluationError

    pub suberror EvaluationError {
    Message(String)
    }

    A dynamic evaluation error, such as a variable that has no binding.

    ParseError

    pub suberror ParseError {
    Syntax(String, Int)
    }

    Internal parse failure.

    ArithmeticOp

    pub(all) enum ArithmeticOp {
    Add
    Subtract
    Multiply
    Divide
    Modulo
    }

    Arithmetic operators.

    Axis

    pub(all) enum Axis {
    Ancestor
    AncestorOrSelf
    Attribute
    Child
    Descendant
    DescendantOrSelf
    Following
    FollowingSibling
    Namespace
    Parent
    Preceding
    PrecedingSibling
    Self
    }

    The thirteen XPath axes.

    ComparisonOp

    pub(all) enum ComparisonOp {
    Equal
    NotEqual
    Less
    LessOrEqual
    Greater
    GreaterOrEqual
    }

    Relational and equality operators.

    EvalContext

    pub struct EvalContext {
    doc :
    Document

    node : Int
    position : Int
    size : Int
    variables : Array[(String, Value)]
    namespaces : Array[(String, String)]
    user_functions : Array[(String, (Array[Expr], EvalContext) -> Value raise EvaluationError)]
    }

    The evaluation context: a context node, its position and size, the variable bindings and the namespace declarations of the stylesheet.

    EvalContext::document

    The document the context evaluates against.

    EvalContext::new

    Create a context for a single node.

    EvalContext::with_function

    fn EvalContext::with_function(self : EvalContext, name : String, function : (Array[Expr], EvalContext) -> Value raise EvaluationError) -> EvalContext

    Return a copy of the context with an extra function implementation.

    EvalContext::with_namespaces

    fn EvalContext::with_namespaces(self : EvalContext, namespaces : Array[(String, String)]) -> EvalContext

    Return a copy of the context with the given stylesheet namespace bindings.

    EvalContext::with_node

    fn EvalContext::with_node(self : EvalContext, node : Int) -> EvalContext

    Return a copy of the context focused on another node.

    EvalContext::with_position

    fn EvalContext::with_position(self : EvalContext, position : Int, size : Int) -> EvalContext

    Return a copy of the context with the given proximity position and size.

    EvalContext::with_variables

    fn EvalContext::with_variables(self : EvalContext, variables : Array[(String, Value)]) -> EvalContext

    Return a copy of the context with the given variable bindings.

    Expr

    pub(all) enum Expr {
    LocationPath(Bool, Array[Step])
    Filter(Expr, Array[Expr])
    Path(Expr, Array[Step])
    Union(Expr, Expr)
    Or(Expr, Expr)
    And(Expr, Expr)
    Comparison(ComparisonOp, Expr, Expr)
    Arithmetic(ArithmeticOp, Expr, Expr)
    Negate(Expr)
    NumberLiteral(Double)
    StringLiteral(String)
    VariableReference(String)
    FunctionCall(String, Array[Expr])
    }

    An XPath expression.

    NodeSet

    pub struct NodeSet {
    nodes : Array[Int]
    }

    An unordered set of nodes, held in document order.

    Nodes are identified by their id in the arena; the document is supplied by the evaluation context so that node-sets do not need to carry it around.

    NodeSet::contains

    fn NodeSet::contains(self : NodeSet, id : Int) -> Bool

    Whether a node belongs to the set.

    NodeSet::empty

    fn NodeSet::empty() -> NodeSet

    The empty node-set.

    NodeSet::first

    fn NodeSet::first(self : NodeSet) -> Int?

    The first node in document order, if any.

    NodeSet::is_empty

    fn NodeSet::is_empty(self : NodeSet) -> Bool

    Whether the set is empty.

    NodeSet::length

    fn NodeSet::length(self : NodeSet) -> Int

    Number of nodes in the set.

    NodeSet::new

    Create a node-set from arbitrary ids, sorting them into document order and removing duplicates.

    NodeSet::nodes

    fn NodeSet::nodes(self : NodeSet) -> ArrayView[Int]

    The nodes, in document order.

    NodeSet::union

    Union of two node-sets.

    NodeTest

    pub(all) enum NodeTest {
    NameTest(String, String)
    TextTest
    CommentTest
    AnyNodeTest
    ProcessingInstructionTest(String?)
    }

    A node test, which filters the nodes selected by an axis.

    ParseErrorInfo

    pub(all) struct ParseErrorInfo {
    message : String
    position : Int
    }

    A syntax error with the offset in the source expression.

    Step

    pub(all) enum Step {
    AxisStep(Axis, NodeTest, Array[Expr])
    SelfStep
    ParentStep
    }

    One step of a location path.

    Token

    pub struct Token {
    kind : TokenKind
    text : String
    position : Int
    }

    A token together with its source offset.

    Token::describe

    fn Token::describe(self : Token) -> String

    Human-readable description used in parse errors.

    TokenKind

    pub(all) enum TokenKind {
    Name
    Number
    Literal
    Slash
    DoubleSlash
    Dot
    DotDot
    At
    LeftParen
    RightParen
    LeftBracket
    RightBracket
    Comma
    ColonColon
    Pipe
    Plus
    Minus
    Star
    Equal
    NotEqual
    Less
    LessOrEqual
    Greater
    GreaterOrEqual
    Dollar
    Eof
    }

    The lexical categories of XPath 1.0.

    Operators that are spelled as names (and, or, div, mod) are lexed as Name and recognised by the parser, as required by the grammar.

    Value

    pub(all) enum Value {
    Nodes(NodeSet)
    Boolean(Bool)
    Number(Double)
    String(String)
    }

    The four XPath value types.

    Value::boolean_value

    fn Value::boolean_value(self : Value) -> Bool

    XPath boolean conversion.

    Value::node_set

    fn Value::node_set(self : Value) -> NodeSet?

    The node-set behind a value, if the value is a node-set.

    Value::number_value

    fn Value::number_value(self : Value, doc :
    Document
    ) -> Double

    XPath number conversion.

    Value::of_boolean

    fn Value::of_boolean(flag : Bool) -> Value

    Wrap a boolean as an XPath value.

    Value::of_nodes

    fn Value::of_nodes(set : NodeSet) -> Value

    Wrap a node-set as an XPath value.

    Value::of_number

    fn Value::of_number(number : Double) -> Value

    Wrap a number as an XPath value.

    Value::of_string

    fn Value::of_string(text : String) -> Value

    Wrap a string as an XPath value.

    Value::string_value

    fn Value::string_value(self : Value, doc :
    Document
    ) -> String

    XPath string conversion.

    boolean_of

    fn boolean_of(context : EvalContext, expression : Expr) -> Result[Bool, String]

    The XPath boolean conversion of an already parsed expression.

    evaluate

    fn evaluate(expression : Expr, context : EvalContext) -> Value raise EvaluationError

    Evaluate an expression against a context.

    evaluate_path

    fn evaluate_path(doc :
    Document
    , node : Int, path : String) -> Result[Value, String]

    Parse and evaluate an expression, returning the raw value.

    evaluate_with

    fn evaluate_with(context : EvalContext, expression : Expr) -> Result[Value, String]

    Evaluate an expression against a context, returning the raw value.

    format_number

    fn format_number(value : Double) -> String

    Format a number the way XPath's string() does.

    Whole numbers are printed without a fractional part and infinities and NaN use their XPath spellings.

    matches_node_test

    fn matches_node_test(doc :
    Document
    , node : Int, axis : Axis, node_test : NodeTest, namespaces : Array[(String, String)]) -> Bool

    Whether a node matches a node node_test on a given axis.

    The namespace declarations of the stylesheet are passed in so that prefixed name tests compare expanded names; when the list is empty, prefixes are compared literally, which keeps the function usable without a stylesheet.

    nan

    fn nan() -> Double

    The IEEE NaN value, which XPath uses for numbers that cannot be represented.

    number_of

    fn number_of(context : EvalContext, expression : Expr) -> Result[Double, String]

    The XPath number conversion of an already parsed expression.

    of_boolean

    fn of_boolean(value : Bool) -> Value

    Wrap a boolean as an XPath value.

    of_number

    fn of_number(value : Double) -> Value

    Wrap a number as an XPath value.

    of_string

    fn of_string(value : String) -> Value

    Wrap a string as an XPath value.

    parse

    fn parse(text : String) -> Result[Expr, ParseErrorInfo]

    Parse an XPath expression.

    parse_expression

    fn parse_expression(text : String) -> Expr raise ParseError

    Parse an XPath expression, raising ParseError on invalid syntax.

    parse_number

    fn parse_number(text : String) -> Double

    Parse an XPath number: optional surrounding whitespace, an optional minus sign, digits with an optional fractional part. Anything else is NaN.

    raise_function_error

    fn[T] raise_function_error(message : String) -> T raise EvaluationError

    Raise a dynamic evaluation error with the given message.

    select

    fn select(doc :
    Document
    , node : Int, path : String) -> Result[NodeSet, String]

    Select the nodes matched by an expression.

    select_boolean

    fn select_boolean(doc :
    Document
    , node : Int, path : String) -> Result[Bool, String]

    The XPath boolean() of an expression result.

    select_nodes

    fn select_nodes(context : EvalContext, expression : Expr) -> Result[NodeSet, String]

    Select the nodes matched by an already parsed expression.

    select_number

    fn select_number(doc :
    Document
    , node : Int, path : String) -> Result[Double, String]

    The XPath number() of an expression result.

    select_string

    fn select_string(doc :
    Document
    , node : Int, path : String) -> Result[String, String]

    The XPath string() of an expression result.

    string_of

    fn string_of(context : EvalContext, expression : Expr) -> Result[String, String]

    The XPath string() of an already parsed expression.

    string_of_node

    fn string_of_node(doc :
    Document
    , id : Int) -> String

    The string-value of a single node.

    Elements and the document node yield the concatenation of their descendant text, attributes and text nodes yield their character data, and comments and processing instructions yield their content.

    tokenize

    fn tokenize(text : String) -> Array[Token]

    Split an XPath expression into tokens.