Mike Cargal created GROOVY-7874:
-----------------------------------

             Summary: XmlSlurper is dropping root noe attributes
                 Key: GROOVY-7874
                 URL: https://issues.apache.org/jira/browse/GROOVY-7874
             Project: Groovy
          Issue Type: Bug
          Components: XML Processing
    Affects Versions: 2.4.7, 2.4.6, 2.4.3
         Environment: MAC OS X, and Windows
            Reporter: Mike Cargal
            Priority: Minor


When parsing an XML document with XmlSlurper, some attributes are being dropped.
Script: ==============
import groovy.xml.*

scSrc = '''<?xml version="1.0" encoding="UTF8"?><xsd:schema 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" 
elementFormDefault="qualified" targetNamespace="urn:cargal.net/myNS" 
xmlns="urn:cargal.net/myNS">
    <xsd:element name="test" type="xsd:string"/>
</xsd:schema>
'''

schema = new XmlSlurper().parseText(scSrc)
println "schema.@attributeFormDefault=${schema.@attributeFormDefault}"
println "schema.@xmlns=${schema.@xmlns}"
println new XmlUtil().serialize(schema)
===============================
results: =========================
schema.@attributeFormDefault=unqualified
schema.@xmlns=
<?xml version="1.0" encoding="UTF-8"?><xsd:schema 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" 
elementFormDefault="qualified" targetNamespace="urn:cargal.net/myNS">
  <xsd:element name="test" type="xsd:string"/>
</xsd:schema>
=================================



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to