Methods
- N
- W
Class Public methods
new( ie_hack=false )
Link
Prints out the XML document with no formatting – except if id_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.
Instance Public methods
write( node, output )
Link
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.
# File lib/rexml/formatters/default.rb, line 21 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
Instance Protected methods
write_cdata( node, output )
Link
write_comment( node, output )
Link
write_document( node, output )
Link
write_element( node, output )
Link
# File lib/rexml/formatters/default.rb, line 63 def write_element( node, output ) output << "<#{node.expanded_name}" node.attributes.to_a.map { |a| Hash === a ? a.values : a }.flatten.sort_by {|attr| attr.name}.each do |attr| output << " " attr.write( output ) end unless node.attributes.empty? if node.children.empty? output << " " if @ie_hack output << "/" else output << ">" node.children.each { |child| write( child, output ) } output << "</#{node.expanded_name}" end output << ">" end
write_instruction( node, output )
Link