groovy
  1. groovy
  2. GROOVY-3170

XmlNodePrinter does not handle attribute namespaces correctly

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.7, 1.6-beta-2
    • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Component/s: XML Processing
    • Labels:
      None
    • Environment:
      Windows XP, Java 1.6.0_06
    • Testcase included:
      yes
    • Patch Submitted:
      Yes
    • Number of attachments :
      2

      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.

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

        Activity

        blackdrag blackdrag made changes -
        Field Original Value New Value
        Assignee Paul King [ paulk ]
        Paul King made changes -
        Affects Version/s 1.5.7 [ 14242 ]
        Affects Version/s 1.6-beta-2 [ 14261 ]
        Component/s XML Processing [ 12201 ]
        Hide
        Paul King added a comment -

        Hi. Thanks for the patch - looking at it now. Just for future reference, patches against trunk are generally greatly preferred over complete source files. But I guess a file is preferred over nothing!

        Show
        Paul King added a comment - Hi. Thanks for the patch - looking at it now. Just for future reference, patches against trunk are generally greatly preferred over complete source files. But I guess a file is preferred over nothing!
        Paul King made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.5.8 [ 14630 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.6-rc-1 [ 14009 ]
        Fix Version/s 1.7-beta-1 [ 14014 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Paul King
            Reporter:
            Zerberus
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: