groovy
  1. groovy
  2. GROOVY-3207

XmlNodePointer does not handle namespace prefixes with repeated URNs

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 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
    • Number of attachments :
      0

      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>
      

        Activity

        Hide
        Alan Boshier added a comment -

        Apologies for inadvertently creating emoticons. Hopefully this will be more readable

        ************************************************************************************************
        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>

        Show
        Alan Boshier added a comment - Apologies for inadvertently creating emoticons. Hopefully this will be more readable ************************************************************************************************ 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>
        Hide
        Paul King added a comment -

        add code tags

        Show
        Paul King added a comment - add code tags
        Hide
        Paul King added a comment -

        I believe this is fixed in trunk. If you can get a chance to try it (you can download a zip/jar from the canoo CI server) that would be great. Otherwise I will try to add an additional test and push through to the 1.6 branch in the next couple of days.

        Show
        Paul King added a comment - I believe this is fixed in trunk. If you can get a chance to try it (you can download a zip/jar from the canoo CI server) that would be great. Otherwise I will try to add an additional test and push through to the 1.6 branch in the next couple of days.
        Hide
        Paul King added a comment -

        Just for the record, here is what I get at the moment in trunk:

        <Foo xmlns="urn:a">
          <f:Bar xmlns:f="urn:a">
            <haha xmlns="urn:b"/>
          </f:Bar>
        </Foo>
        
        Show
        Paul King added a comment - Just for the record, here is what I get at the moment in trunk: <Foo xmlns= "urn:a" > <f:Bar xmlns:f = "urn:a" > <haha xmlns= "urn:b" /> </f:Bar> </Foo>
        Hide
        Paul King added a comment -

        update summary to better reflect real issue

        Show
        Paul King added a comment - update summary to better reflect real issue
        Hide
        Paul King added a comment -

        test added

        Show
        Paul King added a comment - test added

          People

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

            Dates

            • Created:
              Updated:
              Resolved: