module

KXML::XPath

XPath 1.0 evaluation over the KXML DOM, implemented per W3C REC-xpath-19991116.

Constants

AXES = ["child", "descendant", "parent", "ancestor", "following-sibling", "preceding-sibling", "following", "preceding", "attribute", "namespace", "self", "descendant-or-self", "ancestor-or-self"] of ::String

Axis names from section 2.2.

NODE_TYPES = ["node", "text", "comment", "processing-instruction"] of ::String

Class methods

evaluate(expr : String, context : Node | Attribute, position : Int32 = 1, size : Int32 = 1, ns_map : Hash(String, String) | Nil = nil, vars : Hash(String, Value) | Nil = nil) : Value

Evaluates expr with context as the context node. vars binds $name variable references to XPath values; ns_map resolves expression prefixes exclusively (instead of in-scope declarations). The namespace axis works via synthesized namespace nodes and id() resolves ID attributes declared in the internal DTD subset.

Source
evaluate_nodes(expr : String, context : Node | Attribute, position : Int32 = 1, size : Int32 = 1, ns_map : Hash(String, String) | Nil = nil, vars : Hash(String, Value) | Nil = nil) : NodeSet

Like evaluate but requires a node-set result.

Source
expanded_name_of(node : Node | Attribute) : String
Source
local_name_of(node : Node | Attribute) : String

Section 4.2: the local part of an expanded name; empty for the other node kinds.

Source
namespace_uri_of(node : Node | Attribute) : String | Nil
Source
number_to_string(n : Float64) : String

Section 3.5 string(number) conversion.

Source
order_of(node : Node | Attribute) : Int32

Section 5.1: document order is the parser-assigned order number.

Source
sort_nodes(nodes : Enumerable(Node | Attribute)) : NodeSet
Source
string_to_number(s : String) : Float64

Section 4.3 number(string): optional whitespace, optional '-', then digits with at most one '.'; no exponent notation in XPath 1.0.

Source
string_value(node : Node | Attribute) : String

Section 5: string-values.

Source
strip_xml_whitespace(s : String) : String
Source
xpath_round(x : Float64) : Float64

XPath round(): closest integer, ties toward positive infinity; NaN and infinities pass through.

Source

Nested types