diff options
Diffstat (limited to 'lib/rexml/functions.rb')
-rw-r--r-- | lib/rexml/functions.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb index d741dbdab7..cad4f6a8c9 100644 --- a/lib/rexml/functions.rb +++ b/lib/rexml/functions.rb @@ -117,16 +117,30 @@ module REXML elsif defined? object.node_type if object.node_type == :attribute object.value - elsif object.node_type == :element - object.text + elsif object.node_type == :element || object.node_type == :document + string_value(object) else object.to_s end + elsif object.nil? + return "" else object.to_s end end + def Functions::string_value( o ) + rv = "" + o.children.each { |e| + if e.node_type == :text + rv << e.to_s + elsif e.node_type == :element + rv << string_value( e ) + end + } + rv + end + # UNTESTED def Functions::concat( *objects ) objects.join @@ -139,7 +153,7 @@ module REXML # Fixed by Mike Stok def Functions::contains( string, test ) - string(string).include? string(test) + string(string).include?(string(test)) end # Kouhei fixed this @@ -326,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) |