diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-22 09:38:06 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-22 09:38:06 +0000 |
commit | 7a6f34103de55678241471aef582a5aa24622496 (patch) | |
tree | 21114b0a07b18173fca0af800073f0f0dfeb3718 /lib/rexml/element.rb | |
parent | 4d15e619eb1838daafd1510e86c1c8076fb9b227 (diff) | |
download | ruby-7a6f34103de55678241471aef582a5aa24622496.tar.gz |
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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/element.rb')
-rw-r--r-- | lib/rexml/element.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb index ac9b10872c..1ef22d29a2 100644 --- a/lib/rexml/element.rb +++ b/lib/rexml/element.rb @@ -1033,6 +1033,7 @@ module REXML # p attr.expanded_name+" => "+attr.value # } def each_attribute # :yields: attribute + return to_enum(__method__) unless block_given? each_value do |val| if val.kind_of? Attribute yield val @@ -1048,6 +1049,7 @@ module REXML # doc = Document.new '<a x="1" y="2"/>' # doc.root.attributes.each {|name, value| p name+" => "+value } def each + return to_enum(__method__) unless block_given? each_attribute do |attr| yield [attr.expanded_name, attr.value] end |