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

Function stringJoinFunc

func.go:672–700  ·  view source on GitHub ↗

string-join is a XPath Node Set functions string-join(node-set, separator).

(q, arg1 query)

Source from the content-addressed store, hash-verified

670
671// string-join is a XPath Node Set functions string-join(node-set, separator).
672func stringJoinFunc(q, arg1 query) func(query, iterator) interface{} {
673 return func(_ query, t iterator) interface{} {
674 var separator string
675 switch v := functionArgs(arg1).Evaluate(t).(type) {
676 case string:
677 separator = v
678 case query:
679 node := v.Select(t)
680 if node != nil {
681 separator = node.Value()
682 }
683 }
684
685 q = functionArgs(q)
686 test := predicate(q)
687 var parts []string
688 switch v := q.Evaluate(t).(type) {
689 case string:
690 return v
691 case query:
692 for node := v.Select(t); node != nil; node = v.Select(t) {
693 if test(node) {
694 parts = append(parts, node.Value())
695 }
696 }
697 }
698 return strings.Join(parts, separator)
699 }
700}
701
702// lower-case is XPATH function that converts a string to lower case.
703func lowerCaseFunc(arg1 query) func(query, iterator) interface{} {

Callers 1

processFunctionMethod · 0.85

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…