Module amxml::xpath[][src]

XPath Processor (inner module) and helper structs.

Retrieve or apply function to the nodes on XML DOM tree that match the specified xpath.

NodePtr methods eval_xpath(), each_node(), get_first_node(), get_nodeset() accept xpath as argument.

cf. Module amxml::dom -> Struct NodePtr -> Methods.

Specification

Specification of XPath by W3C: XML Path Language (XPath) 3.1

Japanese translation of the document above: XML Path Language (XPath) 3.1: 日本語訳

Notes

This processor supports only some of atomic types: String, Integer, Decimal, Double, Boolean. Features related to 'Type' is restrictive, since this processor does not refer xml schema.

Internally both Decimal and Double are implemented with type f64, but there are some difference. Decimal division 5.0 div 0.0 is error (division by zero), while Double division 5E0 div 0E0 is +Infinity.

Built-in functions that are implemented

  • nilled, string, data
  • abs, ceiling, floor, round
  • codepoints-to-string, string-to-codepoints
  • compare, codepoint-equal
  • concat, string-join, substring, string-length, normalize-space, upper-case, lower-case, translate
  • contains, starts-with, ends-with, substring-before, substring-after
  • true, false
  • not
  • name, local-name, namespace-uri, number, lang, root
  • boolean, index-of
  • empty, exists, head, tail, insert-before, remove, reverse, subsequence
  • zero-or-one, one-or-more, exactly-one
  • count, avg, max, min, sum
  • position, last
  • for-each, filter
  • map:size, map:keys, map:contains, map:get
  • array:size, array:get, array:flatten

Features that are not implemented yet

  • treat as
  • KindTest: SchemaElementTest | SchemaAttributeTest | DocumentTest
  • Many built-in functions that are new in XPath 2.0 and above
  • Collation (in built-in functions: contains, starts-with, etc.)
  • XPath 1.0 compatible mode
  • namespace axis (deprecated as of XPath 2.0)

Structs

Item

Item: either an atomic value or a node.

Sequence

Sequence: return value type of NodePtr#eval_xpath(). This is an ordered collection of zero or more items.