-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 2.4.6
-
Fix Version/s: 2.4.7
-
Component/s: XML Processing
-
Labels:None
According to https://www.w3.org/TR/xml-names/#defaulting the namespace name for an unprefixed attribute name always has no value. Currently when using XmlSlurper unprefixed attributes have the default namespace.
def xml = ''' <root xmlns="urn:test"> <foo id="7">bar</foo> </root> ''' def root = new XmlSlurper(false, true).parseText(xml).declareNamespace(ns: 'urn:test') assert root.foo[0].namespaceURI() == 'urn:test' assert root.'ns:foo'.text() == 'bar' assert root.foo.@id == '7' assert root.foo.'@ns:id' == '' // fails returns 7 assert root.foo.@id[0].namespaceURI() == '' // fails returns 'urn:test'
Based on the specs I believe the following asserts in the XmlSlurperTest are incorrect.
- is related to
-
GROOVY-7781 GPathResult: Cannot retrieve XML attribute with namespace
-
- Closed
-