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

MarkupBuilder DSL bug

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.3.0
    • None
    • XML Processing
    • 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

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

            Dates

              Created:
              Updated: