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
18 lines
659 B
Swift
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?)
|
|
}
|
|
}
|