Groovy Documentation

groovy.xml
[Groovy] Class StreamingMarkupBuilder

java.lang.Object
  groovy.xml.streamingmarkupsupport.AbstractStreamingBuilder
      groovy.xml.StreamingMarkupBuilder

class StreamingMarkupBuilder
extends AbstractStreamingBuilder

A builder class for creating XML markup. This implementation uses a StreamingMarkupWriter to handle output.

Example:

System.out << new StreamingMarkupBuilder().bind {
   root {
     a( a1:'one' ) {
       b { mkp.yield( '3 < 5' ) }
       c( a2:'two', 'blah' )
     }
   }
 }
Will output the following String, without newlines or indentation:
<root>
   <a a1='one'>
     <b>3 &lt; 5</b>
     <c a2='two'>blah</c>
   </a>
 </root>
Notes:


Property Summary
java.lang.Object builder

java.lang.Object commentClosure

Invoked by calling mkp.comment

java.lang.Object declarationClosure

Invoked by calling mkp.xmlDeclaration

java.lang.Object encoding

boolean expandEmptyElements

java.lang.Object noopClosure

Invoked by calling mkp.yield.

java.lang.Object pendingStack

java.lang.Object piClosure

Invoked by calling mkp.pi

java.lang.Object tagClosure

java.lang.Object unescapedClosure

Invoked by calling mkp.yieldUnescaped.

boolean useDoubleQuotes

 
Constructor Summary
StreamingMarkupBuilder()

 
Method Summary
java.lang.Object bind(java.lang.Object closure)

java.lang.Object bindNode(java.lang.Object node)

Convenience method for binding a single node.

java.lang.Object getQt()

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Property Detail

builder

java.lang.Object builder


commentClosure

java.lang.Object commentClosure
Invoked by calling mkp.comment


declarationClosure

java.lang.Object declarationClosure
Invoked by calling mkp.xmlDeclaration


encoding

java.lang.Object encoding


expandEmptyElements

boolean expandEmptyElements


noopClosure

java.lang.Object noopClosure
Invoked by calling mkp.yield. Used to render text to the output stream. Any XML reserved characters will be escaped to ensure well-formedness.


pendingStack

java.lang.Object pendingStack


piClosure

java.lang.Object piClosure
Invoked by calling mkp.pi


tagClosure

java.lang.Object tagClosure


unescapedClosure

java.lang.Object unescapedClosure
Invoked by calling mkp.yieldUnescaped. Used to render literal text or markup to the output stream. No escaping is done on the output.


useDoubleQuotes

boolean useDoubleQuotes


 
Constructor Detail

StreamingMarkupBuilder

StreamingMarkupBuilder()


 
Method Detail

bind

java.lang.Object bind(java.lang.Object closure)

Returns a Writable object, which may be used to render the markup directly to a String, or send the output to a stream.

Examples:

 // get the markup as a string:
 new StreamingMarkupBuilder().bind { div { out << "hello world" } }.toString()
 
 // send the output directly to a file:
 new StreamingMarkupBuilder().bind { div { out << "hello world" } } \
      .writeTo( new File('myFile.xml').newWriter() )
 
Returns:
a Writable to render the markup


bindNode

java.lang.Object bindNode(java.lang.Object node)
Convenience method for binding a single node. The call bindNode(node) is equivalent to bind{ out << node }.

Returns a Writable object, which may be used to render the markup directly to a String, or send the output to a stream.

Returns:
a Writable to render the markup
See Also:
bind(Closure)


getQt

java.lang.Object getQt()


 

Groovy Documentation