You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2016/07/02 02:25:10 UTC

[jira] [Commented] (GROOVY-7878) Prevent namespaces to be inserted in tags

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

Paul King commented on GROOVY-7878:
-----------------------------------

The two XML fragments are technically identical. I presume you have some other system that is broken though and can't handle that form?

> Prevent namespaces to be inserted in tags
> -----------------------------------------
>
>                 Key: GROOVY-7878
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7878
>             Project: Groovy
>          Issue Type: Bug
>          Components: XML Processing
>         Environment: Grails
>            Reporter: Alejandro Godofredo Carlstein Ramos Mejia
>            Priority: Minor
>
> *Short Explanation*
> The engine is removing the namespace from the header and inserting in each tag related with the namespace. This makes the XML result to be unusable in some systems.
> *Long Explanation*
> Let's say we have this XML file :
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <linguacode xmlns="http://xmlns.iqnavigator.com/linguacode/core" xmlns:req="http://xmlns.iqnavigator.com/linguacode/profiles/requisition" xmlns:gsp="http://groovy.codehaus.org/2005/gsp">
>     <organizationKey>${orgKey}</organizationKey>
>     <req:hiringManager>${username}</req:hiringManager>
> </linguacode>
> {code}
> After we bind the map with the information:
> {code}
>        def result = null
>         try{
>             def resource = grailsApplication.mainContext.getResource(xmlTemplateFilename)
>             if (resource.exists()) {
>                 def engine = new XmlTemplateEngine()
>                 result = engine.createTemplate(resource.getFile()).make(mapToBind)
>             }
>         }catch(ex){
>             ex.printStackTrace()
>         }
> {code}
> We get this xml result:
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <linguacode xmlns='http://xmlns.iqnavigator.com/linguacode/core'>
>     <organizationKey>ABC Key</organizationKey>
>     <req:hiringManager xmlns:req="http://xmlns.iqnavigator.com/linguacode/profiles/requisition" >Batman</req:hiringManager>
> </linguacode>
> {code}
> The correct result should be: 
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <linguacode xmlns='http://xmlns.iqnavigator.com/linguacode/core' xmlns:req="http://xmlns.iqnavigator.com/linguacode/profiles/requisition" >
>     <organizationKey>ABC Key</organizationKey>
>     <req:hiringManager>Batman</req:hiringManager>
> </linguacode>
> {code}
> Perhaps adding a flag or some way to inject a closure that would allow us to prevent this behavior would be welcome.
> Everything else is fantastic. Thanks for creating this plugin.



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