# REXML::Document#write: undefined local variable or method \`transitive'

**URL:** <https://www.ruby-forum.com/t/rexml-document-write-undefined-local-variable-or-method-transitive/118135>\
**Category:** Development\
**Created:** [October 24, 2007, 5:46am UTC](https://www.ruby-forum.com/t/rexml-document-write-undefined-local-variable-or-method-transitive/118135 "2007-10-24T05:46:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![akira\_yamada\_S\_SSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/46a35a/32.png) [@akira\_yamada\_S\_SSB](https://www.ruby-forum.com/u/akira_yamada_S_SSB)\
**Post date:** [October 24, 2007, 5:46am UTC](https://www.ruby-forum.com/t/rexml-document-write-undefined-local-variable-or-method-transitive/118135/1 "2007-10-24T05:46:44Z")

</div>

trunke$B$Ne(BREXMLe$B$,85$@$H;W$&$N$G$9$1$Ie(B  
REXML::Document.new("").each\_child{|e|  
e.write($stdout,1,true,true)  
e$B$J$I$GNc30$,\>e$,$j$^$9!#e(B

e$B$I$3$Ge(Brequiree$B$9$k$H$$$$$N$+J,$+$j$^$;$s$,e(B  
e$B$H$j$"$($:$3$s$J$s$G2sHr$G$-$=$&$G$9!#e(B

# Index: lib/rexml/document.rb

— lib/rexml/document.rb (revision 13760)  
+++ lib/rexml/document.rb (working copy)  
@@ -184,7 +184,8 @@  
output = Output.new( output, xml\_decl.encoding )  
end  
formatter = if indent \> -1

- 

```
     if trans

```

- 

```
     if transitive

```

- 

```
       require "rexml/formatters/transitive"
       REXML::Formatters::Transitive.new( indent, ie_hack )
     else
       REXML::Formatters::Pretty.new( indent, ie_hack )

```

# Index: lib/rexml/element.rb

— lib/rexml/element.rb (revision 13760)  
+++ lib/rexml/element.rb (working copy)  
@@ -671,10 +671,11 @@  
# 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
- 

```
       require "rexml/formatters/transitive"
       REXML::Formatters::Transitive.new( indent, ie_hack )
     else
       REXML::Formatters::Pretty.new( indent, ie_hack )

```

# Index: lib/rexml/formatters/transitive.rb

— lib/rexml/formatters/transitive.rb (revision 13760)  
+++ lib/rexml/formatters/transitive.rb (working copy)  
@@ -12,9 +12,10 @@  
# 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 @@  
output \<\< “\n”  
output \<\< ’ '\*@level  
if node.children.empty?

- 

```
     output << " " if @ie_hack
     output << "/"
   else
     output << ">"
```
