summaryrefslogtreecommitdiff
path: root/lib/rexml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rexml')
-rw-r--r--lib/rexml/cdata.rb18
-rw-r--r--lib/rexml/child.rb2
-rw-r--r--lib/rexml/comment.rb12
-rw-r--r--lib/rexml/document.rb20
-rw-r--r--lib/rexml/element.rb34
-rw-r--r--lib/rexml/light/node.rb14
-rw-r--r--lib/rexml/node.rb12
-rw-r--r--lib/rexml/parsers/lightparser.rb8
-rw-r--r--lib/rexml/parsers/sax2parser.rb12
-rw-r--r--lib/rexml/parsers/ultralightparser.rb8
-rw-r--r--lib/rexml/quickpath.rb90
11 files changed, 115 insertions, 115 deletions
diff --git a/lib/rexml/cdata.rb b/lib/rexml/cdata.rb
index 496c6ec9fe9..73358edc289 100644
--- a/lib/rexml/cdata.rb
+++ b/lib/rexml/cdata.rb
@@ -6,15 +6,15 @@ module REXML
STOP = ']]>'
ILLEGAL = /(\]\]>)/
- # Constructor. CData is data between <![CDATA[ ... ]]>
- #
- # _Examples_
- # CData.new( source )
- # CData.new( "Here is some CDATA" )
- # CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element )
- def initialize( first, whitespace=true, parent=nil )
- super( first, whitespace, parent, false, true, ILLEGAL )
- end
+ # Constructor. CData is data between <![CDATA[ ... ]]>
+ #
+ # _Examples_
+ # CData.new( source )
+ # CData.new( "Here is some CDATA" )
+ # CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element )
+ def initialize( first, whitespace=true, parent=nil )
+ super( first, whitespace, parent, false, true, ILLEGAL )
+ end
# Make a copy of this object
#
diff --git a/lib/rexml/child.rb b/lib/rexml/child.rb
index d0b4e352fa3..bf97d5f903e 100644
--- a/lib/rexml/child.rb
+++ b/lib/rexml/child.rb
@@ -7,7 +7,7 @@ module REXML
# class directly.
class Child
include Node
- attr_reader :parent # The Parent of this object
+ attr_reader :parent # The Parent of this object
# Constructor. Any inheritors of this class should call super to make
# sure this method is called.
diff --git a/lib/rexml/comment.rb b/lib/rexml/comment.rb
index d5bb65c51a6..42a040c4565 100644
--- a/lib/rexml/comment.rb
+++ b/lib/rexml/comment.rb
@@ -38,15 +38,15 @@ module REXML
# See REXML::Formatters
#
# output::
- # Where to write the string
+ # Where to write the string
# indent::
- # An integer. If -1, no indenting will be used; otherwise, the
- # indentation will be this number of spaces, and children will be
- # indented an additional amount.
+ # An integer. If -1, no indenting will be used; otherwise, the
+ # indentation will be this number of spaces, and children will be
+ # indented an additional amount.
# transitive::
- # Ignored by this class. The contents of comments are never modified.
+ # Ignored by this class. The contents of comments are never modified.
# ie_hack::
- # Needed for conformity to the child API, but not used by this class.
+ # Needed for conformity to the child API, but not used by this class.
def write( output, indent=-1, transitive=false, ie_hack=false )
Kernel.warn("Comment.write is deprecated. See REXML::Formatters")
indent( output, indent )
diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb
index b4d7aa7e7d8..96db53bdb04 100644
--- a/lib/rexml/document.rb
+++ b/lib/rexml/document.rb
@@ -165,7 +165,7 @@ module REXML
# Document.new("<a><b/></a>").serialize( tr )
#
# output::
- # output an object which supports '<< string'; this is where the
+ # output an object which supports '<< string'; this is where the
# document will be written.
# indent::
# An integer. If -1, no indenting will be used; otherwise, the
@@ -188,15 +188,15 @@ module REXML
output = Output.new( output, xml_decl.encoding )
end
formatter = if indent > -1
- if transitive
- require "rexml/formatters/transitive"
- REXML::Formatters::Transitive.new( indent, ie_hack )
- else
- REXML::Formatters::Pretty.new( indent, ie_hack )
- end
- else
- REXML::Formatters::Default.new( ie_hack )
- end
+ if transitive
+ require "rexml/formatters/transitive"
+ REXML::Formatters::Transitive.new( indent, ie_hack )
+ else
+ REXML::Formatters::Pretty.new( indent, ie_hack )
+ end
+ else
+ REXML::Formatters::Default.new( ie_hack )
+ end
formatter.write( self, output )
end
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb
index 0650824d6de..5991859a788 100644
--- a/lib/rexml/element.rb
+++ b/lib/rexml/element.rb
@@ -20,7 +20,7 @@ module REXML
class Element < Parent
include Namespace
- UNDEFINED = "UNDEFINED"; # The default name
+ UNDEFINED = "UNDEFINED"; # The default name
# Mechanisms for accessing attributes and child elements of this
# element.
@@ -297,7 +297,7 @@ module REXML
el = @elements.add(element)
attrs.each do |key, value|
el.attributes[key]=value
- end if attrs.kind_of? Hash
+ end if attrs.kind_of? Hash
el
end
@@ -667,7 +667,7 @@ module REXML
#
# Writes out this element, and recursively, all children.
# output::
- # output an object which supports '<< string'; this is where the
+ # output an object which supports '<< string'; this is where the
# document will be written.
# indent::
# An integer. If -1, no indenting will be used; otherwise, the
@@ -690,15 +690,15 @@ module REXML
def write(output=$stdout, indent=-1, transitive=false, ie_hack=false)
Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters")
formatter = if indent > -1
- if transitive
- require "rexml/formatters/transitive"
- REXML::Formatters::Transitive.new( indent, ie_hack )
- else
- REXML::Formatters::Pretty.new( indent, ie_hack )
- end
- else
- REXML::Formatters::Default.new( ie_hack )
- end
+ if transitive
+ require "rexml/formatters/transitive"
+ REXML::Formatters::Transitive.new( indent, ie_hack )
+ else
+ REXML::Formatters::Pretty.new( indent, ie_hack )
+ end
+ else
+ REXML::Formatters::Default.new( ie_hack )
+ end
formatter.write( self, output )
end
@@ -778,7 +778,7 @@ module REXML
else
return XPath::first( @element, index )
#{ |element|
- # return element if element.kind_of? Element
+ # return element if element.kind_of? Element
#}
#return nil
end
@@ -1086,7 +1086,7 @@ module REXML
# doc.root.attributes['foo'] = '4'
# doc.root.attributes['x:foo'] = nil
def []=( name, value )
- if value.nil? # Delete the named attribute
+ if value.nil? # Delete the named attribute
attr = get_attribute(name)
delete attr
return
@@ -1116,8 +1116,8 @@ module REXML
value.prefix != "xmlns" and old_attr.prefix != "xmlns" and
@element.namespace( old_attr.prefix ) ==
@element.namespace( value.prefix )
- store value.name, { old_attr.prefix => old_attr,
- value.prefix => value }
+ store value.name, { old_attr.prefix => old_attr,
+ value.prefix => value }
else
store value.name, value
end
@@ -1236,7 +1236,7 @@ module REXML
( !namespace.empty? || !attribute.fully_expanded_name.index(':') )
# foo will match xmlns:foo, but only if foo isn't also an attribute
result = attribute if !result or !namespace.empty? or
- !attribute.fully_expanded_name.index(':')
+ !attribute.fully_expanded_name.index(':')
end
}
result
diff --git a/lib/rexml/light/node.rb b/lib/rexml/light/node.rb
index 07effd07055..0a896c83dcf 100644
--- a/lib/rexml/light/node.rb
+++ b/lib/rexml/light/node.rb
@@ -1,13 +1,13 @@
require 'rexml/xmltokens'
# [ :element, parent, name, attributes, children* ]
-# a = Node.new
-# a << "B" # => <a>B</a>
-# a.b # => <a>B<b/></a>
-# a.b[1] # => <a>B<b/><b/><a>
-# a.b[1]["x"] = "y" # => <a>B<b/><b x="y"/></a>
-# a.b[0].c # => <a>B<b><c/></b><b x="y"/></a>
-# a.b.c << "D" # => <a>B<b><c>D</c></b><b x="y"/></a>
+ # a = Node.new
+ # a << "B" # => <a>B</a>
+ # a.b # => <a>B<b/></a>
+ # a.b[1] # => <a>B<b/><b/><a>
+ # a.b[1]["x"] = "y" # => <a>B<b/><b x="y"/></a>
+ # a.b[0].c # => <a>B<b><c/></b><b x="y"/></a>
+ # a.b.c << "D" # => <a>B<b><c>D</c></b><b x="y"/></a>
module REXML
module Light
# Represents a tagged XML element. Elements are characterized by
diff --git a/lib/rexml/node.rb b/lib/rexml/node.rb
index dabf7a931bd..cab6e9fddb5 100644
--- a/lib/rexml/node.rb
+++ b/lib/rexml/node.rb
@@ -36,12 +36,12 @@ module REXML
end
def indent to, ind
- if @parent and @parent.context and not @parent.context[:indentstyle].nil? then
- indentstyle = @parent.context[:indentstyle]
- else
- indentstyle = ' '
- end
- to << indentstyle*ind unless ind<1
+ if @parent and @parent.context and not @parent.context[:indentstyle].nil? then
+ indentstyle = @parent.context[:indentstyle]
+ else
+ indentstyle = ' '
+ end
+ to << indentstyle*ind unless ind<1
end
def parent?
diff --git a/lib/rexml/parsers/lightparser.rb b/lib/rexml/parsers/lightparser.rb
index 43633f73475..81041681c2e 100644
--- a/lib/rexml/parsers/lightparser.rb
+++ b/lib/rexml/parsers/lightparser.rb
@@ -44,10 +44,10 @@ module REXML
end
# An element is an array. The array contains:
- # 0 The parent element
- # 1 The tag name
- # 2 A hash of attributes
- # 3..-1 The child elements
+ # 0 The parent element
+ # 1 The tag name
+ # 2 A hash of attributes
+ # 3..-1 The child elements
# An element is an array of size > 3
# Text is a String
# PIs are [ :processing_instruction, target, data ]
diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb
index 7c0311aa2e0..0661af37aa7 100644
--- a/lib/rexml/parsers/sax2parser.rb
+++ b/lib/rexml/parsers/sax2parser.rb
@@ -28,15 +28,15 @@ module REXML
# Listen arguments:
#
# Symbol, Array, Block
- # Listen to Symbol events on Array elements
+ # Listen to Symbol events on Array elements
# Symbol, Block
# Listen to Symbol events
# Array, Listener
- # Listen to all events on Array elements
+ # Listen to all events on Array elements
# Array, Block
- # Listen to :start_element events on Array elements
+ # Listen to :start_element events on Array elements
# Listener
- # Listen to All events
+ # Listen to All events
#
# Symbol can be one of: :start_element, :end_element,
# :start_prefix_mapping, :end_prefix_mapping, :characters,
@@ -209,7 +209,7 @@ module REXML
((name.nil? and match.nil?) or match.nil? or (
(name == match) or
(match.kind_of? Regexp and name =~ match)
- )
+ )
)
)
end.collect{|x| x[-1]}
@@ -222,7 +222,7 @@ module REXML
((name.nil? and match.nil?) or match.nil? or (
(name == match) or
(match.kind_of? Regexp and name =~ match)
- )
+ )
)
)
end.collect{|x| x[-1]}
diff --git a/lib/rexml/parsers/ultralightparser.rb b/lib/rexml/parsers/ultralightparser.rb
index 74608458814..7dd81728029 100644
--- a/lib/rexml/parsers/ultralightparser.rb
+++ b/lib/rexml/parsers/ultralightparser.rb
@@ -42,10 +42,10 @@ module REXML
end
# An element is an array. The array contains:
- # 0 The parent element
- # 1 The tag name
- # 2 A hash of attributes
- # 3..-1 The child elements
+ # 0 The parent element
+ # 1 The tag name
+ # 2 A hash of attributes
+ # 3..-1 The child elements
# An element is an array of size > 3
# Text is a String
# PIs are [ :processing_instruction, target, data ]
diff --git a/lib/rexml/quickpath.rb b/lib/rexml/quickpath.rb
index 4925f6a1334..9bec2158dd0 100644
--- a/lib/rexml/quickpath.rb
+++ b/lib/rexml/quickpath.rb
@@ -49,20 +49,20 @@ module REXML
def QuickPath::filter elements, path
return elements if path.nil? or path == '' or elements.size == 0
case path
- when /^\/\//u # Descendant
+ when /^\/\//u # Descendant
return axe( elements, "descendant-or-self", $' )
- when /^\/?\b(\w[-\w]*)\b::/u # Axe
+ when /^\/?\b(\w[-\w]*)\b::/u # Axe
return axe( elements, $1, $' )
- when /^\/(?=\b([:!\w][-\.\w]*:)?[-!\*\.\w]*\b([^:(]|$)|\*)/u # Child
- rest = $'
- results = []
- elements.each do |element|
- results |= filter( element.to_a, rest )
- end
- return results
- when /^\/?(\w[-\w]*)\(/u # / Function
- return function( elements, $1, $' )
- when Namespace::NAMESPLIT # Element name
+ when /^\/(?=\b([:!\w][-\.\w]*:)?[-!\*\.\w]*\b([^:(]|$)|\*)/u # Child
+ rest = $'
+ results = []
+ elements.each do |element|
+ results |= filter( element.to_a, rest )
+ end
+ return results
+ when /^\/?(\w[-\w]*)\(/u # / Function
+ return function( elements, $1, $' )
+ when Namespace::NAMESPLIT # Element name
name = $2
ns = $1
rest = $'
@@ -79,22 +79,22 @@ module REXML
matches |= predicate( element.to_a, path[1..-1] ) if element.kind_of? Element
end
return matches
- when /^\[/u # Predicate
+ when /^\[/u # Predicate
return predicate( elements, path )
- when /^\/?\.\.\./u # Ancestor
+ when /^\/?\.\.\./u # Ancestor
return axe( elements, "ancestor", $' )
- when /^\/?\.\./u # Parent
+ when /^\/?\.\./u # Parent
return filter( elements.collect{|e|e.parent}, $' )
- when /^\/?\./u # Self
+ when /^\/?\./u # Self
return filter( elements, $' )
- when /^\*/u # Any
+ when /^\*/u # Any
results = []
elements.each do |element|
results |= filter( [element], $' ) if element.kind_of? Element
#if element.kind_of? Element
- # children = element.to_a
- # children.delete_if { |child| !child.kind_of?(Element) }
- # results |= filter( children, $' )
+ # children = element.to_a
+ # children.delete_if { |child| !child.kind_of?(Element) }
+ # results |= filter( children, $' )
#end
end
return results
@@ -132,7 +132,7 @@ module REXML
matches = filter(elements.collect{|element| element.parent}.uniq, rest)
when "following-sibling"
matches = filter(elements.collect{|element| element.next_sibling}.uniq,
- rest)
+ rest)
when "previous-sibling"
matches = filter(elements.collect{|element|
element.previous_sibling}.uniq, rest )
@@ -174,32 +174,32 @@ module REXML
predicate.gsub!(
/#{OPERAND_}\s*([<>=])\s*#{OPERAND_}\s*([<>=])\s*#{OPERAND_}/u,
'\1 \2 \3 and \3 \4 \5' )
- # Let's do some Ruby trickery to avoid some work:
- predicate.gsub!( /&/u, "&&" )
- predicate.gsub!( /=/u, "==" )
- predicate.gsub!( /@(\w[-\w.]*)/u, 'attribute("\1")' )
- predicate.gsub!( /\bmod\b/u, "%" )
- predicate.gsub!( /\b(\w[-\w.]*\()/u ) {
- fname = $1
- fname.gsub( /-/u, "_" )
- }
+ # Let's do some Ruby trickery to avoid some work:
+ predicate.gsub!( /&/u, "&&" )
+ predicate.gsub!( /=/u, "==" )
+ predicate.gsub!( /@(\w[-\w.]*)/u, 'attribute("\1")' )
+ predicate.gsub!( /\bmod\b/u, "%" )
+ predicate.gsub!( /\b(\w[-\w.]*\()/u ) {
+ fname = $1
+ fname.gsub( /-/u, "_" )
+ }
- Functions.pair = [ 0, elements.size ]
- results = []
- elements.each do |element|
- Functions.pair[0] += 1
- Functions.node = element
- res = eval( predicate )
- case res
- when true
- results << element
- when Fixnum
- results << element if Functions.pair[0] == res
- when String
- results << element
- end
+ Functions.pair = [ 0, elements.size ]
+ results = []
+ elements.each do |element|
+ Functions.pair[0] += 1
+ Functions.node = element
+ res = eval( predicate )
+ case res
+ when true
+ results << element
+ when Fixnum
+ results << element if Functions.pair[0] == res
+ when String
+ results << element
end
- return filter( results, rest )
+ end
+ return filter( results, rest )
end
def QuickPath::attribute( name )