Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
-
Grails
-
Important
Description
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 :
<?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>
After we bind the map with the information:
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() }
We get this xml result:
<?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>
The correct result should be:
<?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>
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.