Ticket #142 (new defect)

Opened 9 months ago

Last modified 9 months ago

xmlns' showing up in closing tags

Reported by: kitplummer Owned by: ser
Priority: normal Milestone:
Component: DOM Version: 3.1.7
Severity: minor Keywords: namespace
Cc: kitplummer Ruby version: 1.8.6
Operating system: MacOS

Description

I'm creating a very simple XML document with a namespace set in the root tag...which seems to generate the same namespace in the closing tag of the root element, which prevents REXML from creating a new document from the XML.

require 'rexml/document'

=> true

doc = REXML::Document.new

=> UNDEFINED

doc.add_element("testing xmlns='http://www.testing.com'")

=> testing xmlnshttp:wwwtestingcom

doc.root.add_element("inner")

=> inner

doc.write.to_s

<testing xmlns='http://www.testing.com'><inner/></testing xmlns='http://www.testing.com'>=> "<testing xmlns='http://www.testing.com'><inner/></testing xmlns='http://www.testing.com'>"

doc2 = REXML::Document.new(doc.write.to_s)

<testing xmlns='http://www.testing.com'><inner/></testing xmlns='http://www.testing.com'>REXML::ParseException?: #<REXML::ParseException?: #<NoMethodError?: undefined method `[]' for nil:NilClass> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:320:in `pull' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:21:in `parse' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/document.rb:204:in `build' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/document.rb:42:in `initialize' (irb):8:in `new' (irb):8:in `irb_binding' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding' :0 ... Exception parsing Line: Position: Last 80 unconsumed characters: </testing xmlns='http://www.testing.com'>> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:378:in `pull' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:21:in `parse' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/document.rb:204:in `build' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/document.rb:42:in `initialize' (irb):8:in `new' (irb):8:in `irb_binding' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding' :0 ... #<NoMethodError?: undefined method `[]' for nil:NilClass> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:320:in `pull' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:21:in `parse' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/document.rb:204:in `build' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/document.rb:42:in `initialize' (irb):8:in `new' (irb):8:in `irb_binding' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding' :0 ... Exception parsing Line: Position: Last 80 unconsumed characters: </testing xmlns='http://www.testing.com'> Line: Position: Last 80 unconsumed characters: </testing xmlns='http://www.testing.com'>

from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:90:in `parse' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/document.rb:204:in `build' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/document.rb:42:in `initialize' from (irb):8:in `new' from (irb):8 from :0

Here's the version info:

$ ruby -v -rrexml/rexml -e 'p REXML::VERSION,PLATFORM' ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0] "3.1.7.1" "universal-darwin9.0"

Change History

Changed 9 months ago by kitplummer

  • cc kitplummer added

Changed 9 months ago by kitplummer

  • severity changed from major to minor

i suppose this should be major as there is a better way to add namespaces.

Note: See TracTickets for help on using tickets.