MCPcopy Create free account
hub / github.com/antchfx/xpath / axisPredicate

Function axisPredicate

build.go:47–69  ·  view source on GitHub ↗

axisPredicate creates a predicate to predicating for this axis node.

(root *axisNode)

Source from the content-addressed store, hash-verified

45
46// axisPredicate creates a predicate to predicating for this axis node.
47func axisPredicate(root *axisNode) func(NodeNavigator) bool {
48 nametest := root.LocalName != "" || root.Prefix != ""
49 predicate := func(n NodeNavigator) bool {
50 if root.typeTest == n.NodeType() || root.typeTest == allNode {
51 if nametest {
52 type namespaceURL interface {
53 NamespaceURL() string
54 }
55 if ns, ok := n.(namespaceURL); ok && root.hasNamespaceURI {
56 return root.LocalName == n.LocalName() && root.namespaceURI == ns.NamespaceURL()
57 }
58 if root.LocalName == n.LocalName() && root.Prefix == n.Prefix() {
59 return true
60 }
61 } else {
62 return true
63 }
64 }
65 return false
66 }
67
68 return predicate
69}
70
71// processAxis processes a query for the XPath axis node.
72func (b *builder) processAxis(root *axisNode, flags flag, props *builderProp) (query, error) {

Callers 1

processAxisMethod · 0.85

Calls 4

NodeTypeMethod · 0.65
LocalNameMethod · 0.65
NamespaceURLMethod · 0.65
PrefixMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…