|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
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 < 5</b> <c a2='two'>blah</c> </a> </root>Notes:
mkp
is a special namespace used to escape
away from the normal building mode of the builder and get access
to helper markup methods 'yield', 'pi', 'comment', 'out',
'namespaces', 'xmlDeclaration' and 'yieldUnescaped'.
Property Summary | |
---|---|
java.lang.Object |
builder
|
java.lang.Object |
commentClosure
Invoked by calling |
java.lang.Object |
declarationClosure
Invoked by calling |
java.lang.Object |
encoding
|
boolean |
expandEmptyElements
|
java.lang.Object |
noopClosure
Invoked by calling |
java.lang.Object |
pendingStack
|
java.lang.Object |
piClosure
Invoked by calling |
java.lang.Object |
tagClosure
|
java.lang.Object |
unescapedClosure
Invoked by calling |
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 |
---|
java.lang.Object builder
java.lang.Object commentClosure
mkp.comment
java.lang.Object declarationClosure
mkp.xmlDeclaration
java.lang.Object encoding
boolean expandEmptyElements
java.lang.Object noopClosure
mkp.yield
. Used to render text to the
output stream. Any XML reserved characters will be escaped to ensure
well-formedness.
java.lang.Object pendingStack
java.lang.Object piClosure
mkp.pi
java.lang.Object tagClosure
java.lang.Object unescapedClosure
mkp.yieldUnescaped
. Used to render
literal text or markup to the output stream. No escaping is done on the
output.
boolean useDoubleQuotes
Constructor Detail |
---|
StreamingMarkupBuilder()
Method Detail |
---|
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() )
java.lang.Object bindNode(java.lang.Object node)
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.
java.lang.Object getQt()
Groovy Documentation