Wiki source for FunctionStAXwrite


Show raw source

=====Command write=====

This command is part of the [[FunctionsStAX StAX]] support.

====Name====
**write** writes an XML node or characters to a ""StAX Writer"" created with [[FunctionStAXnewStreamWriter newStreamWriter]]


====Synopsis====
write writer value [value ...]


====Description====
write writes XML nodes or charactor dta to a writer created with [[FunctionStAXnewStreamWriter newStreamWriter]].

Note that unlike many of the ""StAX"" functions this is a command not a function. You use the Command syntax to invoke it.

Typically the write command is used instead of the other ""StAX"" write commands when you want to write an XML node which was previously created instead of constructing the XML manually using individual ""StAX"" commands. This is particularly useful when you want to create large XML documents via streaming but want to create parts of the document using more convenient methods which are non-streaming (such as XQuery).


The writer paramter is an writer created with [[FunctionStAXnewStreamWriter newStreamWriter]].
The value parameters are one or more XML objects or character data.



Example
%%
import commands stax=stax


w=stax:newStreamWriter()
stax:writeStartDocument $w
stax:writeStartElement $w foo
stax:write $w <[ <bar>spam</bar> ]> "Text"
stax:writeEndElement $w
stax:writeEndDocument $w
stax:closeWriter $w



%%

Result
%%
<foo>
<bar>spam</bar>Text</foo>
%%


----
[[Commands]]
[[FunctionsStAX StAX Functions]]
[[FunctionStAXnewStreamWriter newStreamWriter]]

[[JavaObjects Java Objects]]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki