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, wait
writeAttribute, writeAttribute
public 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 true
public XmlWriter(Writer os)
Writer
.
The document encoding is fixed by the os
encoding
os
- The output streamprotected IXmlNamespaceManager createNamespaceManager()
public void flushDocument()
IXmlWriter
This is typically used to actually flush the document to an output stream
flushDocument
in interface IXmlWriter
public final IXmlNamespaceManager getNamespaceManager()
getNamespaceManager
in interface IXmlWriter
public 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 IXmlWriter
prefix
- 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)
IXmlWriter
writeCData
in interface IXmlWriter
content
- The content of the CDATA sectionpublic IXmlWriter writeComment(String comment)
IXmlWriter
writeComment
in interface IXmlWriter
comment
- The content of the commentpublic IXmlWriter writeDocumentFragment(Document fragment)
IXmlWriter
writeDocumentFragment
in interface IXmlWriter
public void writeEndDocument()
IXmlWriter
Attempts to write after this method has been called will have undefined results.
writeEndDocument
in interface IXmlWriter
public IXmlWriter writeEndElement()
IXmlWriter
IXmlWriter.writeStartElement(String, String)
or
IXmlWriter.writeStartElement(String, String, String)
.writeEndElement
in interface IXmlWriter
public IXmlWriter writeProcessingInstruction(String target, String data)
IXmlWriter
writeProcessingInstruction
in interface IXmlWriter
target
- The target of the PIdata
- The data of the PIpublic IXmlWriter writeStartDocument()
IXmlWriter
writeStartDocument
in interface IXmlWriter
public 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 IXmlWriter
localName
- 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 IXmlWriter
prefix
- 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 IXmlWriter
s
- The string that gets written as XML text