Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7878

Prevent namespaces to be inserted in tags

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: XML Processing
    • Labels:
      None
    • Environment:
      Grails
    • Flags:
      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              acarlstein Alejandro Godofredo Carlstein Ramos Mejia
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: