groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Cargal (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7874) XmlSlurper is dropping root node attributes
Date Sat, 25 Jun 2016 08:32:41 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15349507#comment-15349507
] 

Mike Cargal commented on GROOVY-7874:
-------------------------------------

Thanks, it helps to know that XmlSlurper identifies and handles namespaces differently than
other attributes.

I had thought about the possibility that the serialization thought these were unused namespace
when I looked at the namespaces that were dropped.

I stripped this down for the example. In my "real" problem, I'm modifying and rewriting schemas
that are included from other schemas (and themselves include schemas).  I'm getting errors
in eclipse on these schemas that I can correct by placing those two namespaces back into these
schemas. So it appears that they are being used even if it's not entirely clear in the context
of the single psd file. It seems that it might be getting too clever in removing "unused"
namespaces.  

I'll try to look a bit further into what's going on and update this.  (i.e. provide an example
that demonstrates how these removals actually cause a problem.)

thanks

Just curious, in the mean time, is there some work around for me to get these namespaces forced
back into my output?

> XmlSlurper is dropping root node 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.3, 2.4.6, 2.4.7
>         Environment: MAC OS X, and Windows
>            Reporter: Mike Cargal
>            Priority: Minor
>
> When parsing an XML document with XmlSlurper, some attributes are being dropped.
> {code}
> 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)
> {code}
> results:
> {noformat}
> 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>
> {noformat}



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

Mime
View raw message