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

MarkupBuilder DSL bug

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3.0
    • Fix Version/s: None
    • Component/s: XML Processing
    • Labels:
      None

      Description

      import groovy.util.slurpersupport.NamespaceAwareHashMap
      import groovy.xml.XmlUtil
      
      class Test {
          public static void main(String[] args) {
              def source = '''
      <test>
      </test>
      '''
      
              def slurper = new XmlSlurper()
              def document = slurper.parseText(source);
      
              document << {
                  qqq()
              }
              
              document << new groovy.util.slurpersupport.Node(null, "qqq", new NamespaceAwareHashMap(), [:], "");
              
              document.children().'**'*.@mass = "!!!"
              
              println XmlUtil.serialize( document )
          }
      }
      

      This code provides this:

      <?xml version="1.0" encoding="UTF-8"?><test>
        <qqq/>
        <qqq mass="!!!"/>
      </test>
      

      But it should be:

      <?xml version="1.0" encoding="UTF-8"?><test>
        <qqq mass="!!!"/>
        <qqq mass="!!!"/>
      </test>
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bsideup Sergei Egorov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: