1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
Author: akira yamada <akira@debian.org>
Description: REXML::Document#write(io, 1, true, true) raises NameError/ArgumentError
--- a/lib/rexml/document.rb
+++ b/lib/rexml/document.rb
@@ -186,6 +186,7 @@ module REXML
end
formatter = if indent > -1
if trans
+ require "rexml/formatters/transitive"
REXML::Formatters::Transitive.new( indent, ie_hack )
else
REXML::Formatters::Pretty.new( indent, ie_hack )
--- a/lib/rexml/element.rb
+++ b/lib/rexml/element.rb
@@ -675,6 +675,7 @@ module REXML
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 )
--- a/lib/rexml/formatters/transitive.rb
+++ b/lib/rexml/formatters/transitive.rb
@@ -12,9 +12,10 @@ module REXML
# formatted. Since this formatter does not alter whitespace nodes, the
# results of formatting already formatted XML will be odd.
class Transitive < Default
- def initialize( indentation=2 )
+ def initialize( indentation=2, ie_hack=false )
@indentation = indentation
@level = 0
+ @ie_hack = ie_hack
end
protected
@@ -29,6 +30,7 @@ module REXML
output << "\n"
output << ' '*@level
if node.children.empty?
+ output << " " if @ie_hack
output << "/"
else
output << ">"
|