PureXML/Sources/XPath/NodeTest.swift
Mihaela Mihaljevic 6b7853f2d5 feat(xpath): all thirteen axes via parent-aware navigation
Rebuild the XPath engine on the parent-aware tree. Add an XPath node
abstraction (tree, attribute, namespace) with document order, and navigate
all thirteen axes: child, descendant, parent, ancestor, following-sibling,
preceding-sibling, following, preceding, attribute, namespace, self,
descendant-or-self, ancestor-or-self. Support the ./../@/// abbreviations
and processing-instruction() node tests. Reverse axes number nearest-first
for positional predicates; results return de-duplicated in document order.
The attribute axis excludes xmlns declarations; the namespace axis surfaces
in-scope namespace nodes.

Closes #40
2026-06-08 05:15:14 +02:00

18 lines
659 B
Swift

extension PureXML.XPath {
/// The node test of a location step: which nodes on the axis qualify.
enum NodeTest: Equatable {
/// A name match (`book`), tested against the axis's principal node kind.
case name(String)
/// The `*` wildcard (any node of the axis's principal kind).
case wildcard
/// `text()`: character-data and CDATA nodes.
case text
/// `node()`: any node.
case node
/// `comment()`: comment nodes.
case comment
/// `processing-instruction()`: PI nodes, optionally with a target literal.
case processingInstruction(target: String?)
}
}