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

Function namespaceFunc

func.go:205–227  ·  view source on GitHub ↗

namespaceFunc is a XPath functions namespace-uri([node-set]).

(arg query)

Source from the content-addressed store, hash-verified

203
204// namespaceFunc is a XPath functions namespace-uri([node-set]).
205func namespaceFunc(arg query) func(query, iterator) interface{} {
206 return func(_ query, t iterator) interface{} {
207 var v NodeNavigator
208 if arg == nil {
209 v = t.Current()
210 } else {
211 // Get the first node in the node-set if specified.
212 v = arg.Clone().Select(t)
213 if v == nil {
214 return ""
215 }
216 }
217 // fix about namespace-uri() bug: https://github.com/antchfx/xmlquery/issues/22
218 // TODO: In the next version, add NamespaceURL() to the NodeNavigator interface.
219 type namespaceURL interface {
220 NamespaceURL() string
221 }
222 if f, ok := v.(namespaceURL); ok {
223 return f.NamespaceURL()
224 }
225 return v.Prefix()
226 }
227}
228
229func asBool(t iterator, v interface{}) bool {
230 switch v := v.(type) {

Callers 1

processFunctionMethod · 0.85

Calls 5

PrefixMethod · 0.95
CurrentMethod · 0.65
SelectMethod · 0.65
CloneMethod · 0.65
NamespaceURLMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…