de.zeigermann.xml
Class XMLOutputStreamWriter
public class XMLOutputStreamWriter
Adds XML export functionality to the underlying output stream. Formatting and
encoding is done as straight forward as possible.
Everything you know better than this class must be done by you, e.g. you will
have to tell
XMLOutputStreamWriter
where you wish to have
newlines.In effect, no unexpected so called
intelligent behavior is to be feared. Another effect is high speed.
Caution: Do not forget to call
XMLOutputStreamWriter
at the end of your
exporting process as otherwise no data might be written.
Warning: When using two byte encoding (e.g. UTF-16) underlying
OutputStream can
not savely be brought to string. Do
not use
ByteArrayOutputStream
with two byte encoding, as XML declaration
will be in single byte encoding (according to XML spec) and the rest will be
in double byte totally confusing ByteArrayOutputStream encoding to string.
If you want to have string output use XMLWriter
filtering
StringWriter
or for convenience XMLStringWriter
.
String | getEncodingName() - Gets the name of the encoding as it would be inserted into the
XML declaration.
|
void | writeXMLDeclaration() - Writes XML delcaration using version 1.0 and encoding specified in
constructor.
|
createEmptyTag , createEmptyTag , createEmptyTag , createEmptyTag , createEmptyTag , createEndTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , createStartTag , generateAndWriteElementWithCData , generateAndWriteElementWithCData , getNlAfterEmptyTag , getNlAfterEndTag , getNlAfterStartTag , getPrettyPrintMode , getTabWidth , isXMLDeclarationWritten , setNlAfterEmptyTag , setNlAfterEndTag , setNlAfterStartTag , setPrettyPrintMode , setTabWidth , setXMLDeclarationWritten , writeCData , writeComment , writeElementWithCData , writeElementWithPCData , writeEmptyElement , writeEmptyElement , writeEndTag , writeEndTag , writeNl , writePCData , writePI , writeProlog , writeStartTag , writeStartTag , writeXMLDeclaration |
ENCODING_ISO_8859_1
public static String ENCODING_ISO_8859_1
Name of ISO-8859-1 encoding
ENCODING_ISO_LATIN1
public static String ENCODING_ISO_LATIN1
Alias for ISO-8859-1 encoding
ENCODING_STANDARD
public static String ENCODING_STANDARD
Name of standard encoding
ENCODING_UTF_16
public static String ENCODING_UTF_16
Name of UTF-16 encoding
ENCODING_UTF_8
public static String ENCODING_UTF_8
Name of UTF-8 encoding
encodingName
protected String encodingName
os
protected OutputStream os
XMLOutputStreamWriter
public XMLOutputStreamWriter(OutputStream os)
throws UnsupportedEncodingException
Creates a new output stream writer for XML export. Standard encoding
will be used as found in
ENCODING_STANDARD
, which usually is
UTF-8.
XMLOutputStreamWriter
public XMLOutputStreamWriter(OutputStream os,
String encodingName)
throws UnsupportedEncodingException
Creates a new output stream writer for XML export.
encodingName
- name of the encoding used to write XML as well as
for the XML declataration (e.g. UTF-8, ISO-8859-1, ...)
getEncodingName
public String getEncodingName()
Gets the name of the encoding as it would be inserted into the
XML declaration. OutputStreamWriter.getEncoding
may return something less verbose.
OutputStreamWriter.getEncoding
writeXMLDeclaration
public void writeXMLDeclaration()
throws IOException
Writes XML delcaration using version 1.0 and encoding specified in
constructor.
Caution: As XML declaration must be in plain text (no UNICODE)
it will not be passed to writer, but directly to stream!
- writeXMLDeclaration in interface XMLWriter
Copyright © 2002-2004 Oliver Zeigermann. All Rights Reserved.