`namespace-uri()` returns the wrong value for attributes
arthurdarcet opened this issue · comments
Arthur Darcet commented
For attributes, namespace-uri()
always returns the NS of the parent tag:
var data = `<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="root-ns" xmlns:nested="nested-ns">
<tag nested:attr="val"></tag>
</root>
`
func main() {
buf := strings.NewReader(data)
doc, _ := xmlquery.Parse(buf)
fmt.Println(len(xmlquery.Find(doc, "//*[namespace-uri()='root-ns' and local-name()='tag']"))) // 1
fmt.Println(len(xmlquery.Find(doc, "//*[@*[namespace-uri()='nested-ns' and local-name()='attr']]"))) // 0
fmt.Println(len(xmlquery.Find(doc, "//*[@*[namespace-uri()='root-ns' and local-name()='attr']]"))) // 1
}
should output 1 1 0
, but returns 1 0 1