You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Alejandro Godofredo Carlstein Ramos Mejia (JIRA)" <ji...@apache.org> on 2016/07/01 19:23:10 UTC

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

Alejandro Godofredo Carlstein Ramos Mejia created GROOVY-7878:
-----------------------------------------------------------------

             Summary: 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


*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)