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

FilteredNodeChildren doesn't provide childNodes() iterator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.3
    • 2.1.4, 2.2.0-beta-1
    • XML Processing
    • None
    • JDK 6
    • Patch

    Description

      Given the standard XML example from the documentation, the following GPath expressions did not return the same result:

      records.car.country
      records.car.findAll({ true }).country
      

      The reason is a missing implementation of childNodes() in FilteredNodeChildren.

      Merging the code patterns for flattening all the child iterators in NodeChildren and for filtering with the lazy-evaluated closure originally passed to the parent via .findAll() in the existing iterator implementations of FilteredNodeChildren.

      The suggested implementation (uploaded) passes all the assert in the documentation example. It also passes these additional asserts, proving that two findAll() filters can be chained and the GPath can be further extended beyond the filter:

      assert records.car.findAll({ true }).country == 'AustraliaIsle of ManFrance'
      assert records.car.findAll({ it.@make =~ /e/ }).record.@type == 'speedsize'
      assert records.car.findAll({ true }).findAll({ it.@make =~ /ug/ }).country == 'France'
      

      Attachments

        1. FilteredNodeChildren.java
          4 kB
          Jochen Eddelbuettel

        Activity

          People

            paulk Paul King
            eddelplus Jochen Eddelbuettel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: