mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Merged from REXML main repository:
Fixes ticket:68. NOTE that this involves an API change! Entity declarations in the doctype now generate events that carry two, not one, arguments. Implements ticket:15, using gwrite's suggestion. This allows Element to be subclassed. Two unrelated changes, because subversion is retarded and doesn't do block-level commits: 1) Fixed a typo bug in previous change for ticket:15 2) Fixed namespaces handling in XPath and element. ***** Note that this is an API change!!! ***** Element.namespaces() now returns a hash of namespace mappings which are relevant for that node. Fixes a bug in multiple decodings The changeset 1230:1231 was bad. The default behavior is *not* to use the native REXML encodings by default, but rather to use ICONV by default. I know that this will piss some people off, but defaulting to the pure Ruby version isn't the correct solution, and it breaks other encodings, so I've reverted it. * Fixes ticket:61 (xpath_parser) * Fixes ticket:63 (UTF-16; UNILE decoding was bad) * Cleans up some tests, removing opportunities for test corruption * Improves parsing error messages a little * Adds the ability to override the encoding detection in Source construction * Fixes an edge case in Functions::string, where document nodes weren't correctly converted * Fixes Functions::string() for Element and Document nodes * Fixes some problems in entity handling Addresses ticket:66 Fixes ticket:71 Addresses ticket:78 NOTE: that this also fixes what is technically another bug in REXML. REXML's XPath parser used to allow exponential notation in numbers. The XPath spec is specific about what a number is, and scientific notation is not included. Therefore, this has been fixed. Cross-ported a fix for ticket:88 from CVS. Fixes ticket:80 Documentation cleanup. Ticket:84 Applied Kou's fix for an un-trac'ed bug. ------------------------------------------------------------------------ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f700c1354f
commit
fa4bfa6af5
13 changed files with 142 additions and 83 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue