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

XML NodeList.add(index, Node) does not work as expected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6
    • 1.7.2, 1.8-beta-1
    • XML Processing
    • None
    • Mac OS X

    Description

      The following test fails - the new node is always inserted at the end of the list

      def xml = "<parent><child id=\"1\"/></parent>"
      def parent = new XmlParser().parseText(xml)
      def node = new Node(parent, "child", [id:"2"])
      parent.child.add(0, node)
      assert parent.child[0] == node
      

      The following test fails too - In this case, the second assertions fails - the node is inserted twice!

      def xml = "<parent><child id=\"1\"/></parent>"
      def parent = new XmlParser().parseText(xml)
      def node = new Node(parent, "child", [id:"2"])
      parent.children().add(0, node)
      assert parent.children()[0] == node
      assert parent.children()[2] != node
      

      Attachments

        Activity

          People

            paulk Paul King
            peter.rietzler@smarter-ecommerce.com Peter Rietzler
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: