Wiki source for FunctionStAXnewStreamWriter


Show raw source

=====Function newStreamWriter=====

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

====Name====
**newStreamWriter** creates a new ""StAX"" [[http://download.oracle.com/javase/6/docs/api/javax/xml/stream/XMLStreamWriter.html XMLStreamWriter]] Object


====Synopsis====
newStreamWriter( [file] )


====Description====

newStreamWritercreates an instance of a ""StAX"" [[http://download.oracle.com/javase/6/docs/api/javax/xml/stream/XMLStreamWriter.html XMLStreamWriter]] object initialized to write to the standard output port, or if supplied, a file.

The result object should be stored in a variable for use by other [[FunctionsStAX StAX Functions]].
This object is actually a real instance of the ""XMLStreamWriter"" interface, and you can use the [[JavaObjects Java Objects]] method call syntax to access it,
it is easier and more efficient to use the functions in the [[FunctionsStAX StAX Functions]] which provide a higher level interface.

To use the ""StAX"" functions you need to [[CommandImport import]] them into either the global namespace or a local namespace.
Its recommended that you use a local namespace so that there is less chance of name collisions.


Example
%%
import commands stax=stax

w=stax:newStreamWriter()
stax:writeStartDocument $w
stax:writeStartElement $w QName( xmlsh http://www.xmlsh.org/test1 test )
stax:writeNamespace $w xmlsh2 http://www.xmlsh.org/test2
stax:writeAttribute $w QName( xmlsh2 http://www.xmlsh.org/test2 a1) value1
stax:writeCharacters $w "Some Characters"
stax:writeComment $w "This is a comment"
stax:writeStartElement $w inner
stax:writeCData $w "This is CData"
stax:writeEndElement $w
stax:writeEndElement $w
stax:writeEndDocument $w


stax:closeWriter $w

%%


----
[[Commands]]
[[FunctionsStAX StAX Functions]]
[[JavaObjects Java Objects]]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki