Class: REXML::Formatters::Default
- Defined in:
- lib/rexml/formatters/default.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(ie_hack = false) ⇒ Default
constructor
Prints out the XML document with no formatting – except if ie_hack is set.
-
#write(node, output) ⇒ Object
Writes the node to some output.
Constructor Details
#initialize(ie_hack = false) ⇒ Default
Prints out the XML document with no formatting – except if ie_hack is set.
- ie_hack
-
If set to true, then inserts whitespace before the close of an empty tag, so that IE’s bad XML parser doesn’t choke.
12 13 14 |
# File 'lib/rexml/formatters/default.rb', line 12 def initialize( ie_hack=false ) @ie_hack = ie_hack end |
Instance Method Details
#write(node, output) ⇒ Object
Writes the node to some output.
- node
-
The node to write
- output
-
A class implementing
<<
. Pass in an Output object to change the output encoding.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rexml/formatters/default.rb', line 23 def write( node, output ) case node when Document if node.xml_decl.encoding != 'UTF-8' && !output.kind_of?(Output) output = Output.new( output, node.xml_decl.encoding ) end write_document( node, output ) when Element write_element( node, output ) when Declaration, ElementDecl, NotationDecl, ExternalEntity, Entity, Attribute, AttlistDecl node.write( output,-1 ) when Instruction write_instruction( node, output ) when DocType, XMLDecl node.write( output ) when Comment write_comment( node, output ) when CData write_cdata( node, output ) when Text write_text( node, output ) else raise Exception.new("XML FORMATTING ERROR") end end |