[ruby-cvs:70327] kou:r63237 (trunk): rexml: Fix XPath bug of //#{ELEMENT_NAME}[#{POSITION}]

kou at ruby-lang.org kou at ruby-lang.org
Sun Apr 22 18:38:06 JST 2018


kou	2018-04-22 18:38:06 +0900 (Sun, 22 Apr 2018)

  New Revision: 63237

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63237

  Log:
    rexml: Fix XPath bug of //#{ELEMENT_NAME}[#{POSITION}]
    
    The position should be counted for each nodeset but the previous
    implementation counts position for union-ed nodeset.
    
    For example, "/a/*/*[1]" should be matched to "<c1/>" and "<c2/>" with
    the following XML.
    
        <a>
          <b>
            <c1/>
          </b>
          <b>
            <c2/>
          </b>
        </a>
    
    But the previous implementation just returns only "<c1/>".
    
    * lib/rexml/element.rb (REXML::Attributes#each_attribute):
      Support Enumerator for no block use.
    
    * lib/rexml/element.rb (REXML::Attributes#each):
      Support Enumerator for no block use.
    
    * lib/rexml/functions.rb (REXML::Functions.string):
      Support NaN again.
    
    * lib/rexml/xpath_parser.rb: Re-implement "Step" evaluator.
      It should evaluate "AxisSpecifier", "NodeTest" and "Predicate" in one
      step to respect position for each nodeset.
    
    * test/rexml/test_jaxen.rb: Enable more tests. Remained tests should
      be also enabled but it'll not be near future.
    
    * test/rexml/xpath/test_base.rb: Fix expected value.

  Modified files:
    trunk/lib/rexml/element.rb
    trunk/lib/rexml/functions.rb
    trunk/lib/rexml/xpath_parser.rb
    trunk/test/rexml/test_jaxen.rb
    trunk/test/rexml/xpath/test_base.rb


More information about the ruby-cvs mailing list