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

XmlNodePointer does not handle namespace prefixes with repeated URNs

    XMLWordPrintableJSON

Details

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

    Description

      There are still problems with the XML Namespace handling of XmlNodePrinter in 1.6 Beta 2. The following code parses valid XML and then writes it out to a string. The string no longer contains valid XML because one of the namespace prefixes has been lost.

      def x="<Foo xmlns='urn:a' xmlns:f='urn:a'><f:Bar xmlns='urn:b'><haha/></f:Bar></Foo>"
      def y = new XmlParser(false, true).parseText(x)
      def writer = new StringWriter()
      def xnp = new XmlNodePrinter(new PrintWriter(writer))
      xnp.namespaceAware = true
      xnp.print(y)
      print writer.toString()
      

      Output is (note missing declaration for namespace prefix f

      <Foo xmlns="urn:a">
        <f:Bar>
          <haha xmlns="urn:b"/>
        </f:Bar>
      </Foo>
      

      Attachments

        Activity

          People

            paulk Paul King
            wabrit Alan Boshier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: