[
https://issues.apache.org/jira/browse/GROOVY-3905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149437#comment-18149437
]
ASF GitHub Bot commented on GROOVY-3905:
----------------------------------------
daniellansun opened a new pull request, #3335:
URL: https://github.com/apache/groovy/pull/3335
https://issues.apache.org/jira/browse/GROOVY-3905
XmlParser used to ignore prefix mappings that were not used as element or
attribute names, so XmlNodePrinter dropped declarations such as `xmlns:xs` when
the prefix appeared only inside an attribute value, for example
`xsi:type="xs:string"`. The parser now records those bindings on the node, and
the printer writes a binding when an attribute value contains a `prefix:local`
token that is in scope and not already declared. Unused bindings are omitted.
A null attribute map is treated as empty, so a node constructed with a null
attributes map prints again. Attribute values that are any `CharSequence`,
including a `GString` or `StringBuilder`, are scanned. Prefixes reserved by XML
(those that start with `xml` in any case) are not redeclared.
`testGroovy3905` now runs as a regular test; its assertions are unchanged.
Additional coverage is in `XmlNodePrinterTest`.
> XMLNodePrinter doesn't keep namespace required for attribute value
> ------------------------------------------------------------------
>
> Key: GROOVY-3905
> URL: https://issues.apache.org/jira/browse/GROOVY-3905
> Project: Groovy
> Issue Type: Bug
> Components: XML Processing
> Affects Versions: 1.6.5
> Environment: Groovy 1.6.5 / Linux
> Reporter: Nicolas Nobelis
> Assignee: Daniel Sun
> Priority: Major
> Attachments: NameSpaceTest.groovy, TableReportSimpleRequest.xml
>
>
> I have a SOAP request containing the following stanza :
> <filterValue *xmlns:xs="http://www.w3.org/2001/XMLSchema"*
> xsi:type="xs:string">gaucho</filterValue>
> However, XMLNodePrinter outputs :
> <filterValue xsi:type="xs:string">gaucho</filterValue>
> I looked in the source of XMLNodePrinter, and it seems that, since an
> element/attribute with the prefix 'xs' is never encountered, the
> corresponding call to _printNamespace_ is never done.
> The processed xml give me an Unmarshalling Exception from the web service
> because the namespace 'xs' is then not bound. I understand that usually,
> namespaces that are not used in the XML don't have to be outputted, but still
> I do not feel comfortable with XMLNodePrinter removing some of my
> declarations.
> You will find in attachment the raw SOAP request and a sample Groovy script
> to test it (this is not a unit test).
> Thanks in advance
> N.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)