diff options
author | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-20 04:31:57 +0000 |
---|---|---|
committer | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-20 04:31:57 +0000 |
commit | 66aeb2f7080dea92703f10546fb3cbcc946f6fa3 (patch) | |
tree | 4dfe958e610386eb752d60ad26a8f1702e1eb650 /lib/rexml/element.rb | |
parent | 00190701e0b8cc9ce5dbe9c836e9584d1c1caeb8 (diff) | |
download | ruby-66aeb2f7080dea92703f10546fb3cbcc946f6fa3.tar.gz |
r1479@bean: ser | 2008-01-19 14:26:31 -0500
r1483@bean: ser | 2008-01-19 14:47:23 -0500
Sam's fixes:
* Don't blow up on empty documents
* Add a test case for sorted attributes
* Making the output predictable simplifies unit tests, and doesn't cost
much given that most xml element have few attributes
* Ruby 1.9 revision 14922 is more strict
* Complete Ticket #134
* Fix for ticket #121
* Fix for ticket #124
* Fix for ticket #128
* Fix ticket #133
* Ticket #131 (Support Ruby 1.9)
* Fix for ticket #127
* Fix for ticket #123
* Add missing data needed by test case
r1481@bean (orig r1303): ser | 2008-01-19 17:22:32 -0500
Tagged for release
r1482@bean (orig r1304): ser | 2008-01-19 17:27:10 -0500
Version bump
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/element.rb')
-rw-r--r-- | lib/rexml/element.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb index 55094111e6..ecd10de965 100644 --- a/lib/rexml/element.rb +++ b/lib/rexml/element.rb @@ -558,7 +558,19 @@ module REXML prefix = namespaces.index(namespace) if namespace end prefix = nil if prefix == 'xmlns' - attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" ) + + ret_val = + attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" ) + + return ret_val unless ret_val.nil? + return nil if prefix.nil? + + # now check that prefix'es namespace is not the same as the + # default namespace + return nil unless ( namespaces[ prefix ] == namespaces[ 'xmlns' ] ) + + attributes.get_attribute( name ) + end # Evaluates to +true+ if this element has any attributes set, false @@ -675,7 +687,7 @@ module REXML # out = '' # doc.write( out ) #-> doc is written to the string 'out' # doc.write( $stdout ) #-> doc written to the console - def write(writer=$stdout, indent=-1, transitive=false, ie_hack=false) + 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 @@ -1217,14 +1229,17 @@ module REXML # # Method contributed by Henrik Martensson def get_attribute_ns(namespace, name) + result = nil each_attribute() { |attribute| if name == attribute.name && namespace == attribute.namespace() && ( !namespace.empty? || !attribute.fully_expanded_name.index(':') ) - return attribute + # 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(':') end } - nil + result end end end |