namespaceFunc is a XPath functions namespace-uri([node-set]).
(arg query)
| 203 | |
| 204 | // namespaceFunc is a XPath functions namespace-uri([node-set]). |
| 205 | func 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 | |
| 229 | func asBool(t iterator, v interface{}) bool { |
| 230 | switch v := v.(type) { |
no test coverage detected
searching dependent graphs…