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/04 04:57:10 UTC
[jira] [Resolved] (GROOVY-7878) Prevent namespaces to be inserted
in tags
[ https://issues.apache.org/jira/browse/GROOVY-7878?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alejandro Godofredo Carlstein Ramos Mejia resolved GROOVY-7878.
---------------------------------------------------------------
Resolution: Fixed
I just happen to solve the issue I was having.
Instead of using the common constructor:
def engine = new XmlTemplateEngine()
I needed to use this other contructor, XmlTemplateEngine(XmlParser xmlParser, GroovyShell groovyShell) by using
XmlParser(boolean validating, boolean namespaceAware)
def xmlParser = new XmlParser(true, false)
def groovyShell = new GroovyShell()
def engine = XmlTemplateEngine(xmlParser, groovyShell)
> 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)