summaryrefslogtreecommitdiff
path: root/lib/rexml/functions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rexml/functions.rb')
-rw-r--r--lib/rexml/functions.rb25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb
index d741dbdab7..8293e9c5ac 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
@@ -325,8 +339,9 @@ module REXML
object.to_f
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)