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

XmlNodePrinter does not handle attribute namespaces correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.7, 1.6-beta-2
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • XML Processing
    • None
    • Windows XP, Java 1.6.0_06
    • Patch

    Description

      The following script fails, because XmlNodePrinter ignores the attribute namespace. The output of writer.toString() is <root

      {www.foo.bar}

      type="foo"/>

      def attributeWithNamespaceInput = "<root ns1:type=\"foo\" xmlns:ns1=\"www.foo.bar\"/>\n"
      def root = new XmlParser().parseText(attributeWithNamespaceInput)
      def writer = new StringWriter()
      new XmlNodePrinter(new PrintWriter(writer)).print(root)
      assert writer.toString() == attributeWithNamespaceInput

      I attached a fix for XmlNodePrinter and updated the corresponding test class.

      Attachments

        1. XmlNodePrinter.java
          11 kB
          Zerberus
        2. XmlNodePrinterTest.groovy
          4 kB
          Zerberus

        Activity

          People

            paulk Paul King
            the-zerberus Zerberus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: