@@ 340,7 340,9 @@ module REXML
else
str = string( object )
#puts "STRING OF #{object.inspect} = #{str}"
- if str =~ /^-?\.?\d/
+ # If XPath ever gets scientific notation...
+ #if str =~ /^\s*-?(\d*\.?\d+|\d+\.)([Ee]\d*)?\s*$/
+ if str =~ /^\s*-?(\d*\.?\d+|\d+\.)\s*$/
str.to_f
else
(0.0 / 0.0)
@@ 24,9 24,9 @@ class TC_Rexml_Functions_Number < Test::
telem.text="-9.13"
assert_equal(-9.13, REXML::Functions::number(telem))
end
- def test_functions_number_scientific_notation
- telem = REXML::Element.new("elem")
- telem.text="9.13E12"
- assert_equal(9.13E12, REXML::Functions::number(telem))
- end
-end
No newline at end of file
+ #def test_functions_number_scientific_notation
+ # telem = REXML::Element.new("elem")
+ # telem.text="9.13E12"
+ # assert_equal(9.13E12, REXML::Functions::number(telem))
+ #end
+end
@@ 735,7 735,7 @@ class XPathTester < Test::Unit::TestCase
assert_equal( 1, XPath.match( d, xp2 ).length )
assert_equal( 1, XPath.match( d, xp3 ).length )
assert_equal( 0, XPath.match( d, xp4 ).length )
- assert_equal( 1, XPath.match( d, xp5 ).length )
+ assert_equal( 0, XPath.match( d, xp5 ).length )
assert_equal( 0, XPath.match( d, xp6 ).length )
assert_equal( 0, XPath.match( d, xp7 ).length )
assert_equal( 0, XPath.match( d, xp8 ).length )
@@ 1012,4 1012,28 @@ EOF
el2 = XPath.first( doc.root, "element[@ns:attrname='foo']", { 'ns' => "xyz" } )
assert_equal( el, el2 )
end
+
+ def test_ticket_78
+ doc = <<-EOT
+ <root>
+ <element>
+ <tag x='1'>123</tag>
+ </element>
+ <element>
+ <tag x='2'>123a</tag>
+ </element>
+ </root>
+ EOT
+ seq = %w{BEGIN 123 END BEGIN 123a END}
+
+ xmlDoc = Document.new(doc)
+
+ ["//element[tag='123']/tag", "//element[tag='123a']/tag"].each do |query|
+ assert_equal( "BEGIN", seq.shift )
+ XPath.each(xmlDoc, query) { |element|
+ assert_equal( seq.shift, element.text )
+ }
+ assert_equal( "END", seq.shift )
+ end
+ end
end