mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
All of the tickets and issues mentioned in this log can be found at:
http://www.germane-software.com/projects/rexml/ticket/# where '#' is the issue or ticket number. * Fixes ticket:3 (Issue38 in Roundup.) However, this needs further testing. * Fixed a couple of bugs in the SAX2 parser, plus a bunch of other changes I don't remember. * More XPath ordering testing added * Fixed the documentation WRT the raw mode of text nodes (ticket:4) * Fixes roundup issue 43: substring-after bug. See: http://www.germane-software.com/cgi-bin/roundup/rexml/issue43 * Fixed issue44, Element#xpath * Patch submitted by an anonymous doner to allow parsing of Tempfiles. I was hoping that, by now, that whole Source thing would have been changed to use duck typing and avoid this sort of issue... but in the meantime, the patch has been applied. * Fixes ticket:30, XPath default namespace bug. The fix was provided by Lucas Nussbaum. * Aliases #size to #length, as per zdennis's request. * Fixes typo from previous commit * Fixes ticket #32 (and adds a unit test) * Merges a user-contributed patch for issue #40 * Changes Date, Version, and Copyright to upper case, to avoid conflicts with the Date class. * Minor, yet incomplete, documentation changes. * Resolves issue #34 (SAX parser change makes it impossible to parse IO feeds.) * Moves parser.source.position() to parser.position() * Improves the build script (less work for me to package a distribution) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2ffedb5f29
commit
f8d68a2482
10 changed files with 47 additions and 31 deletions
|
@ -713,7 +713,7 @@ module REXML
|
||||||
|
|
||||||
private
|
private
|
||||||
def __to_xpath_helper node
|
def __to_xpath_helper node
|
||||||
rv = node.expanded_name
|
rv = node.expanded_name.clone
|
||||||
if node.parent
|
if node.parent
|
||||||
results = node.parent.find_all {|n|
|
results = node.parent.find_all {|n|
|
||||||
n.kind_of?(REXML::Element) and n.expanded_name == node.expanded_name
|
n.kind_of?(REXML::Element) and n.expanded_name == node.expanded_name
|
||||||
|
|
|
@ -157,12 +157,9 @@ module REXML
|
||||||
# Kouhei fixed this too
|
# Kouhei fixed this too
|
||||||
def Functions::substring_after( string, test )
|
def Functions::substring_after( string, test )
|
||||||
ruby_string = string(string)
|
ruby_string = string(string)
|
||||||
ruby_index = ruby_string.index(string(test))
|
test_string = string(test)
|
||||||
if ruby_index.nil?
|
return $1 if ruby_string =~ /#{test}(.*)/
|
||||||
""
|
""
|
||||||
else
|
|
||||||
ruby_string[ ruby_index+1..-1 ]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Take equal portions of Mike Stok and Sean Russell; mix
|
# Take equal portions of Mike Stok and Sean Russell; mix
|
||||||
|
|
|
@ -31,9 +31,11 @@ module REXML
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete( object )
|
def delete( object )
|
||||||
return unless @children.include? object
|
found = false
|
||||||
@children.delete object
|
@children.delete_if {|c|
|
||||||
object.parent = nil
|
c.equal?(object) and found = true
|
||||||
|
}
|
||||||
|
object.parent = nil if found
|
||||||
end
|
end
|
||||||
|
|
||||||
def each(&block)
|
def each(&block)
|
||||||
|
@ -131,15 +133,16 @@ module REXML
|
||||||
@children.size
|
@children.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias :length :size
|
||||||
|
|
||||||
# Replaces one child with another, making sure the nodelist is correct
|
# Replaces one child with another, making sure the nodelist is correct
|
||||||
# @param to_replace the child to replace (must be a Child)
|
# @param to_replace the child to replace (must be a Child)
|
||||||
# @param replacement the child to insert into the nodelist (must be a
|
# @param replacement the child to insert into the nodelist (must be a
|
||||||
# Child)
|
# Child)
|
||||||
def replace_child( to_replace, replacement )
|
def replace_child( to_replace, replacement )
|
||||||
ind = @children.index( to_replace )
|
@children.map! {|c| c.equal?( to_replace ) ? replacement : c }
|
||||||
to_replace.parent = nil
|
to_replace.parent = nil
|
||||||
@children[ind,0] = replacement
|
replacement.parent = self
|
||||||
replacement.parent = self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deeply clones this object. This creates a complete duplicate of this
|
# Deeply clones this object. This creates a complete duplicate of this
|
||||||
|
|
|
@ -128,6 +128,8 @@ module REXML
|
||||||
@source = source
|
@source = source
|
||||||
elsif defined? StringIO and source.kind_of? StringIO
|
elsif defined? StringIO and source.kind_of? StringIO
|
||||||
@source = IOSource.new(source)
|
@source = IOSource.new(source)
|
||||||
|
elsif defined? Tempfile and source.kind_of? Tempfile
|
||||||
|
@source = IOSource.new(source)
|
||||||
else
|
else
|
||||||
raise "#{source.class} is not a valid input stream. It must be \n"+
|
raise "#{source.class} is not a valid input stream. It must be \n"+
|
||||||
"either a String, IO, StringIO or Source."
|
"either a String, IO, StringIO or Source."
|
||||||
|
@ -139,6 +141,15 @@ module REXML
|
||||||
@entities = []
|
@entities = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def position
|
||||||
|
if @source.respond_to? :position
|
||||||
|
@source.position
|
||||||
|
else
|
||||||
|
# FIXME
|
||||||
|
0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Returns true if there are no more events
|
# Returns true if there are no more events
|
||||||
def empty?
|
def empty?
|
||||||
#puts "@source.empty? = #{@source.empty?}"
|
#puts "@source.empty? = #{@source.empty?}"
|
||||||
|
|
|
@ -32,6 +32,7 @@ module REXML
|
||||||
def_delegators( :@parser, :has_next? )
|
def_delegators( :@parser, :has_next? )
|
||||||
def_delegators( :@parser, :entity )
|
def_delegators( :@parser, :entity )
|
||||||
def_delegators( :@parser, :empty? )
|
def_delegators( :@parser, :empty? )
|
||||||
|
def_delegators( :@parser, :source )
|
||||||
|
|
||||||
def initialize stream
|
def initialize stream
|
||||||
@entities = {}
|
@entities = {}
|
||||||
|
|
|
@ -167,7 +167,7 @@ module REXML
|
||||||
:elementdecl, :cdata, :notationdecl, :xmldecl
|
:elementdecl, :cdata, :notationdecl, :xmldecl
|
||||||
handle( *event )
|
handle( *event )
|
||||||
end
|
end
|
||||||
handle( :progress, @parser.source.position )
|
handle( :progress, @parser.position )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
#
|
#
|
||||||
# Main page:: http://www.germane-software.com/software/rexml
|
# Main page:: http://www.germane-software.com/software/rexml
|
||||||
# Author:: Sean Russell <serATgermaneHYPHENsoftwareDOTcom>
|
# Author:: Sean Russell <serATgermaneHYPHENsoftwareDOTcom>
|
||||||
# Version:: 3.1.3
|
# Version:: 3.1.3.1
|
||||||
# Date:: 2005/224
|
# Date:: 2005/364
|
||||||
#
|
#
|
||||||
# This API documentation can be downloaded from the REXML home page, or can
|
# This API documentation can be downloaded from the REXML home page, or can
|
||||||
# be accessed online[http://www.germane-software.com/software/rexml_doc]
|
# be accessed online[http://www.germane-software.com/software/rexml_doc]
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
# or can be accessed
|
# or can be accessed
|
||||||
# online[http://www.germane-software.com/software/rexml/docs/tutorial.html]
|
# online[http://www.germane-software.com/software/rexml/docs/tutorial.html]
|
||||||
module REXML
|
module REXML
|
||||||
Copyright = "Copyright © 2001, 2002, 2003, 2004 Sean Russell <ser@germane-software.com>"
|
Copyright = "Copyright © 2001-2005 Sean Russell <ser@germane-software.com>"
|
||||||
Date = "2005/224"
|
Date = "2005/364"
|
||||||
Version = "3.1.3"
|
Version = "3.1.3.1"
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,11 +8,12 @@ module REXML
|
||||||
# @return a Source, or nil if a bad argument was given
|
# @return a Source, or nil if a bad argument was given
|
||||||
def SourceFactory::create_from arg#, slurp=true
|
def SourceFactory::create_from arg#, slurp=true
|
||||||
if arg.kind_of? String
|
if arg.kind_of? String
|
||||||
source = Source.new(arg)
|
Source.new(arg)
|
||||||
elsif arg.kind_of? IO
|
elsif arg.kind_of? IO
|
||||||
source = IOSource.new(arg)
|
IOSource.new(arg)
|
||||||
|
elsif arg.kind_of? Source
|
||||||
|
arg
|
||||||
end
|
end
|
||||||
source
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -199,7 +200,7 @@ module REXML
|
||||||
end
|
end
|
||||||
|
|
||||||
def position
|
def position
|
||||||
@er_source.pos
|
@er_source.stat.pipe? ? 0 : @er_source.pos
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return the current line in the source
|
# @return the current line in the source
|
||||||
|
|
|
@ -39,8 +39,10 @@ module REXML
|
||||||
# text. If this value is nil (the default), then the raw value of the
|
# text. If this value is nil (the default), then the raw value of the
|
||||||
# parent will be used as the raw value for this node. If there is no raw
|
# parent will be used as the raw value for this node. If there is no raw
|
||||||
# value for the parent, and no value is supplied, the default is false.
|
# value for the parent, and no value is supplied, the default is false.
|
||||||
|
# Use this field if you have entities defined for some text, and you don't
|
||||||
|
# want REXML to escape that text in output.
|
||||||
# Text.new( "<&", false, nil, false ) #-> "<&"
|
# Text.new( "<&", false, nil, false ) #-> "<&"
|
||||||
# Text.new( "<&", false, nil, true ) #-> IllegalArgumentException
|
# Text.new( "<&", false, nil, true ) #-> Parse exception
|
||||||
# Text.new( "<&", false, nil, true ) #-> "<&"
|
# Text.new( "<&", false, nil, true ) #-> "<&"
|
||||||
# # Assume that the entity "s" is defined to be "sean"
|
# # Assume that the entity "s" is defined to be "sean"
|
||||||
# # and that the entity "r" is defined to be "russell"
|
# # and that the entity "r" is defined to be "russell"
|
||||||
|
@ -156,11 +158,11 @@ module REXML
|
||||||
# # Assume that the entity "s" is defined to be "sean", and that the
|
# # Assume that the entity "s" is defined to be "sean", and that the
|
||||||
# # entity "r" is defined to be "russell"
|
# # entity "r" is defined to be "russell"
|
||||||
# t = Text.new( "< & sean russell", false, nil, false, ['s'] )
|
# t = Text.new( "< & sean russell", false, nil, false, ['s'] )
|
||||||
# t.string #-> "< & sean russell"
|
# t.value #-> "< & sean russell"
|
||||||
# t = Text.new( "< & &s; russell", false, nil, false )
|
# t = Text.new( "< & &s; russell", false, nil, false )
|
||||||
# t.string #-> "< & sean russell"
|
# t.value #-> "< & sean russell"
|
||||||
# u = Text.new( "sean russell", false, nil, true )
|
# u = Text.new( "sean russell", false, nil, true )
|
||||||
# u.string #-> "sean russell"
|
# u.value #-> "sean russell"
|
||||||
def value
|
def value
|
||||||
@unnormalized if @unnormalized
|
@unnormalized if @unnormalized
|
||||||
doctype = nil
|
doctype = nil
|
||||||
|
|
|
@ -152,9 +152,10 @@ module REXML
|
||||||
#puts "IN QNAME"
|
#puts "IN QNAME"
|
||||||
prefix = path_stack.shift
|
prefix = path_stack.shift
|
||||||
name = path_stack.shift
|
name = path_stack.shift
|
||||||
ns = @namespaces[prefix]
|
default_ns = @namespaces[prefix]
|
||||||
ns = ns ? ns : ''
|
default_ns = default_ns ? default_ns : ''
|
||||||
nodeset.delete_if do |node|
|
nodeset.delete_if do |node|
|
||||||
|
ns = default_ns
|
||||||
# FIXME: This DOUBLES the time XPath searches take
|
# FIXME: This DOUBLES the time XPath searches take
|
||||||
ns = node.namespace( prefix ) if node.node_type == :element and ns == ''
|
ns = node.namespace( prefix ) if node.node_type == :element and ns == ''
|
||||||
#puts "NS = #{ns.inspect}"
|
#puts "NS = #{ns.inspect}"
|
||||||
|
@ -347,7 +348,7 @@ module REXML
|
||||||
preceding_siblings = all_siblings[ 0 .. current_index-1 ].reverse
|
preceding_siblings = all_siblings[ 0 .. current_index-1 ].reverse
|
||||||
#results += expr( path_stack.dclone, preceding_siblings )
|
#results += expr( path_stack.dclone, preceding_siblings )
|
||||||
end
|
end
|
||||||
nodeset = preceding_siblings
|
nodeset = preceding_siblings || []
|
||||||
node_types = ELEMENTS
|
node_types = ELEMENTS
|
||||||
|
|
||||||
when :preceding
|
when :preceding
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue