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

Function countFunc

func.go:78–93  ·  view source on GitHub ↗

countFunc is a XPath Node Set functions count(node-set).

(arg query)

Source from the content-addressed store, hash-verified

76
77// countFunc is a XPath Node Set functions count(node-set).
78func countFunc(arg query) func(query, iterator) interface{} {
79 return func(_ query, t iterator) interface{} {
80 var count = 0
81 q := functionArgs(arg)
82 test := predicate(q)
83 switch typ := q.Evaluate(t).(type) {
84 case query:
85 for node := typ.Select(t); node != nil; node = typ.Select(t) {
86 if test(node) {
87 count++
88 }
89 }
90 }
91 return float64(count)
92 }
93}
94
95// sumFunc is a XPath Node Set functions sum(node-set).
96func sumFunc(arg query) func(query, iterator) interface{} {

Callers 1

processFunctionMethod · 0.85

Calls 4

functionArgsFunction · 0.85
predicateFunction · 0.85
EvaluateMethod · 0.65
SelectMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…