Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.4.6
-
None
Description
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.
Attachments
Issue Links
- is related to
-
GROOVY-7781 GPathResult: Cannot retrieve XML attribute with namespace
- Closed