public class XmlWriter extends Object implements IXmlWriter
IXmlWriter that writes directly to an output stream.
This writer does not support random access on the output document.
| Constructor and Description |
|---|
XmlWriter(OutputStream os,
Charset enc)
Create a new instance that writes on the given stream with a specified encoding.
|
XmlWriter(OutputStream os,
Charset enc,
boolean indent)
Create a new instance that writes on the given stream with a specified encoding.
|
XmlWriter(Writer os)
Create a new instance that writes on a
Writer. |
XmlWriter(Writer os,
boolean indent)
Create a new instance that writes on a
Writer. |
| Modifier and Type | Method and Description |
|---|---|
protected IXmlNamespaceManager |
createNamespaceManager()
Factory method that creates the namespace manager for this instance.
|
void |
flushDocument()
Close the document.
|
IXmlNamespaceManager |
getNamespaceManager()
Gets the namespace manager associated with this writer.
|
IXmlWriter |
writeAttribute(String prefix,
String localName,
String ns,
String value)
Write a XML attribute node.
|
IXmlWriter |
writeCData(String content)
Write a CDATA section.
|
IXmlWriter |
writeComment(String comment)
Write a XML comment node.
|
IXmlWriter |
writeDocumentFragment(Document fragment)
Write a document fragment.
|
void |
writeEndDocument()
Close the output.
|
IXmlWriter |
writeEndElement()
Close a XML element previously opened with
IXmlWriter.writeStartElement(String, String) or
IXmlWriter.writeStartElement(String, String, String). |
IXmlWriter |
writeProcessingInstruction(String target,
String data)
Write a xml processing instruction.
|
IXmlWriter |
writeStartDocument()
Begin the output process.
|
IXmlWriter |
writeStartElement(String localName,
String ns)
Begin a new XML element with given parameters.
|
IXmlWriter |
writeStartElement(String prefix,
String s,
String ns)
Begin a new XML element with given parameters.
|
IXmlWriter |
writeString(String s)
Write a text node.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwriteAttribute, writeAttributepublic XmlWriter(OutputStream os, Charset enc)
os - The output streamenc - The document encodingpublic XmlWriter(OutputStream os, Charset enc, boolean indent)
os - The output streamenc - The document encodingindent - Whether the output should be indented or not. Default is truepublic XmlWriter(Writer os)
Writer.
The document encoding is fixed by the os encoding
os - The output streamprotected IXmlNamespaceManager createNamespaceManager()
public void flushDocument()
IXmlWriterThis is typically used to actually flush the document to an output stream
flushDocument in interface IXmlWriterpublic final IXmlNamespaceManager getNamespaceManager()
getNamespaceManager in interface IXmlWriterpublic IXmlWriter writeAttribute(String prefix, String localName, String ns, String value)
IXmlWriter
The attribute is attached to the closest open XML element that has been started with IXmlWriter.writeStartElement(String, String)
or IXmlWriter.writeStartElement(String, String, String)
writeAttribute in interface IXmlWriterprefix - The namespace prefix of the attributelocalName - The local name of the attributens - The namespace URI of this attributevalue - The value of this attributepublic IXmlWriter writeCData(String content)
IXmlWriterwriteCData in interface IXmlWritercontent - The content of the CDATA sectionpublic IXmlWriter writeComment(String comment)
IXmlWriterwriteComment in interface IXmlWritercomment - The content of the commentpublic IXmlWriter writeDocumentFragment(Document fragment)
IXmlWriterwriteDocumentFragment in interface IXmlWriterpublic void writeEndDocument()
IXmlWriterAttempts to write after this method has been called will have undefined results.
writeEndDocument in interface IXmlWriterpublic IXmlWriter writeEndElement()
IXmlWriterIXmlWriter.writeStartElement(String, String) or
IXmlWriter.writeStartElement(String, String, String).writeEndElement in interface IXmlWriterpublic IXmlWriter writeProcessingInstruction(String target, String data)
IXmlWriterwriteProcessingInstruction in interface IXmlWritertarget - The target of the PIdata - The data of the PIpublic IXmlWriter writeStartDocument()
IXmlWriterwriteStartDocument in interface IXmlWriterpublic IXmlWriter writeStartElement(String localName, String ns)
IXmlWriter
All subsequent output is attached to this element until IXmlWriter.writeEndElement() has been called or a new element has
been started.
This acts like IXmlWriter.writeStartElement(String, String, String), but uses the default prefix for the namespace
writeStartElement in interface IXmlWriterlocalName - The local name of this elementns - The namespace of this elementpublic IXmlWriter writeStartElement(String prefix, String s, String ns)
IXmlWriter
All subsequent output is attached to this element until IXmlWriter.writeEndElement() has been called or a new element has
been started.
writeStartElement in interface IXmlWriterprefix - The namespace prefix to use for this elements - The local name of this elementns - The namespace of this elementpublic IXmlWriter writeString(String s)
IXmlWriter
The string value of s will be correctly escaped
writeString in interface IXmlWriters - The string that gets written as XML text