Groovy
  1. Groovy
  2. GROOVY-3170

XmlNodePrinter does not handle attribute namespaces correctly

    Details

    • Type: Bug Bug
    • Status: 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
    • Flags:
      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.

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

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        4d 12h 5m 1 Paul King 29/Nov/08 19:48
        Resolved Resolved Closed Closed
        23d 10h 10m 1 Paul King 23/Dec/08 05:58
        Mark Thomas made changes -
        Workflow jira [ 12968513 ] Default workflow, editable Closed status [ 12976153 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Patch Submitted Yes [ 10763 ]
        Flags Patch [ 10430 ]
        Mark Thomas made changes -
        Workflow jira [ 12732171 ] Default workflow, editable Closed status [ 12743967 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Paul King made changes -
        Fix Version/s 1.6-rc-1 [ 14009 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.5.8 [ 14630 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.7-beta-1 [ 14014 ]
        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 -
        Affects Version/s 1.5.7 [ 14242 ]
        Affects Version/s 1.6-beta-2 [ 14261 ]
        Component/s XML Processing [ 12201 ]
        Jochen Theodorou made changes -
        Field Original Value New Value
        Assignee Paul King [ paulk ]
        Zerberus created issue -

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development