public class XmlStreamWriter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static XmlStreamWriter |
defaultInstance |
Constructor and Description |
---|
XmlStreamWriter()
Initialize the new instance with default values.
|
Modifier and Type | Method and Description |
---|---|
void |
appendDocumentStart(java.io.Writer writer,
java.lang.String encoding)
Appends the start line of an XML document to the given writer.
|
void |
appendDocumentStart(java.io.Writer writer,
java.lang.String encoding,
boolean isStandalone)
Appends the start line of an XML document to the given writer.
|
void |
appendDocumentType(java.io.Writer writer,
java.lang.String rootTagName,
java.lang.String dtdURL)
Appends the document type (DOCTYPE) line to the given writer using the
SYSTEM parameter to specify the DTD location.
|
void |
appendDocumentType(java.io.Writer writer,
java.lang.String rootTagName,
java.lang.String schemaName,
java.lang.String dtdURL)
Appends the document type (DOCTYPE) line to the given writer using the
PUBLIC parameter if the given schameName is not null or the SYSTEM parameter
to just specify the DTD location.
|
void |
appendDOM(org.w3c.dom.Document document,
java.io.Writer writer)
Appends the given document to the specified writer as XML representation.
|
void |
appendDOMElement(org.w3c.dom.Element element,
java.io.Writer writer)
Appends the given DOM element to the specified writer as XML string representation.
|
void |
appendSIXElement(Element element,
java.io.Writer writer)
Appends the given element and its children to the specified writer
as XML representation.
|
void |
appendStylesheetPI(java.io.Writer writer,
java.util.Map<java.lang.String,java.lang.String> attributes)
Appends a stylesheet processing instruction with the given attributes.
|
void |
appendStylesheetPI(java.io.Writer writer,
NamedTextList attributes)
Appends a stylesheet processing instruction with the given attributes.
|
void |
appendStylesheetPI(java.io.Writer writer,
java.lang.String attributes)
Appends a stylesheet processing instruction with the given attributes.
|
void |
appendWellFormedXML(Element element,
java.io.Writer writer,
java.lang.String encoding)
Appends the given element tree as a well formed XML to the given writer.
|
void |
appendWellFormedXML(Element element,
java.io.Writer writer,
java.lang.String encoding,
java.lang.String dtdURL)
Appends the given element tree as a well formed XML to the given writer.
|
void |
appendWellFormedXML(Element element,
java.io.Writer writer,
java.lang.String encoding,
java.lang.String schemaName,
java.lang.String dtdURL)
Appends the given element tree as a well formed XML to the given writer.
|
void |
appendXslStylesheetPI(java.io.Writer writer,
java.lang.String xslFilename)
Appends an XSL stylesheet processing instruction for the given XSL filename
|
int |
getIndentation()
Returns the current indentation.
|
protected char |
getQuoteChar() |
protected boolean |
getUsingDoubleQuotes() |
protected static Logger |
logger()
Returns the current logger used by this component to report
errors and exceptions.
|
static XmlStreamWriter |
n()
Returns a new instance of this class
|
protected DOMTreeXMLReader |
newXMLReader() |
void |
setIndentation(int newValue)
Sets the current indentation.
|
protected void |
setUsingDoubleQuotes(boolean newValue) |
protected StringUtil |
str() |
void |
useDoubleQuotes()
Configures this writer to use double quotes (") to enclose
XML attribute values.
|
void |
useSingleQuotes()
Configures this writer to use single quotes (') to enclose
XML attribute values.
|
boolean |
withNamespacePrefix()
Returns whether or not the namespace prefix is written as well.
|
void |
withNamespacePrefix(boolean newValue)
Sets whether or not the namespace prefix is written as well.
|
static void |
writeDocumentStart(java.io.Writer writer,
java.lang.String encoding)
Writes the start line of an XML document to the given writer.
|
static void |
writeDocumentStart(java.io.Writer writer,
java.lang.String encoding,
boolean isStandalone)
Writes the start line of an XML document to the given writer.
|
static void |
writeDocumentType(java.io.Writer writer,
java.lang.String rootTagName,
java.lang.String dtdURL)
Writes the document type line to the given writer.
|
static void |
writeDocumentType(java.io.Writer writer,
java.lang.String rootTagName,
java.lang.String schemaName,
java.lang.String dtdURL)
Writes the document type line to the given writer.
|
static void |
writeDOM(org.w3c.dom.Document document,
java.io.Writer writer)
Write the given document to the specified writer as XML representation.
|
protected void |
writeQuoted(java.io.Writer writer,
java.lang.String text) |
static void |
writeSIXElement(Element element,
java.io.Writer writer)
Write the given element and its children to the specified writer
as XML representation.
|
static void |
writeWellFormedXML(Element element,
java.io.Writer writer,
java.lang.String encoding)
Writes the given element tree as a well formed XML stream.
|
static void |
writeWellFormedXML(Element element,
java.io.Writer writer,
java.lang.String encoding,
java.lang.String dtdURL)
Writes the given element tree as a well formed XML stream.
|
static void |
writeWellFormedXML(Element element,
java.io.Writer writer,
java.lang.String encoding,
java.lang.String schemaName,
java.lang.String dtdURL)
Writes the given element tree as a well formed XML to the given writer.
|
protected static final XmlStreamWriter defaultInstance
public XmlStreamWriter()
public boolean withNamespacePrefix()
public void withNamespacePrefix(boolean newValue)
public int getIndentation()
public void setIndentation(int newValue)
public static void writeWellFormedXML(Element element, java.io.Writer writer, java.lang.String encoding)
element
- The root element of an XML tree.writer
- The writer that receives the output.encoding
- A valid encoding name or null to omit the attribute.public static void writeWellFormedXML(Element element, java.io.Writer writer, java.lang.String encoding, java.lang.String dtdURL)
element
- The root element of an XML tree.writer
- The writer that receives the output.encoding
- A valid encoding name or null to omit the attribute.dtdURL
- The url to locate the document's DTD (might be null).public static void writeWellFormedXML(Element element, java.io.Writer writer, java.lang.String encoding, java.lang.String schemaName, java.lang.String dtdURL)
element
- The root element of an XML tree (must not be null).writer
- The writer that receives the output (must not be null).encoding
- A valid encoding name or null to omit the attribute.schemaName
- The logical name of the schema for the DOCTYPE PUBLIC definition (might be null).dtdURL
- The URL to locate the document's DTD in the DOCTYPE SYSTEM or PUBLIC definition (might be null).public static void writeDocumentStart(java.io.Writer writer, java.lang.String encoding)
writer
- The writer that receives the output.encoding
- A valid encoding name or null to omit the attribute.public static void writeDocumentStart(java.io.Writer writer, java.lang.String encoding, boolean isStandalone)
writer
- The writer that receives the outputencoding
- A valid encoding name or null to omit the attribute.isStandalone
- If true the standalone="yes" attribute will be added.public static void writeDocumentType(java.io.Writer writer, java.lang.String rootTagName, java.lang.String dtdURL)
writer
- The writer that receives the output (must not be null).rootTagName
- The name of the document's root tag (must not be null).dtdURL
- The URL to locate the document's DTD (must not be null).public static void writeDocumentType(java.io.Writer writer, java.lang.String rootTagName, java.lang.String schemaName, java.lang.String dtdURL)
writer
- The writer that receives the output (must not be null).rootTagName
- The name of the document's root tag (must not be null).schemaName
- The logical name of the schema (e.g. "-//W3C//DTD XHTML 1.0 Strict//EN").
This parameter may be null or blank which means SYSTEM will be used rather than PUBLIC.dtdURL
- The URL to locate the document's DTD (must not be null).public static void writeSIXElement(Element element, java.io.Writer writer)
element
- Usually the root element of an XML treewriter
- The writer that will receive the outputpublic static void writeDOM(org.w3c.dom.Document document, java.io.Writer writer)
document
- A valid DOM treewriter
- The writer that will receive the outputpublic static XmlStreamWriter n()
protected static Logger logger()
public void useSingleQuotes()
public void useDoubleQuotes()
public void appendWellFormedXML(Element element, java.io.Writer writer, java.lang.String encoding)
element
- The root element of an XML treewriter
- The writer that receives the outputencoding
- A valid encoding name or null to omit the attributepublic void appendWellFormedXML(Element element, java.io.Writer writer, java.lang.String encoding, java.lang.String dtdURL)
element
- The root element of an XML treewriter
- The writer that receives the outputencoding
- A valid encoding name or null to omit the attributedtdURL
- The URL to locate the document's DTD (might be null)public void appendWellFormedXML(Element element, java.io.Writer writer, java.lang.String encoding, java.lang.String schemaName, java.lang.String dtdURL)
element
- The root element of an XML tree (must not be null).writer
- The writer that receives the output (must not be null).encoding
- A valid encoding name or null to omit the attribute.schemaName
- The logical name of the schema for the DOCTYPE PUBLIC definition (might be null).dtdURL
- The URL to locate the document's DTD in the DOCTYPE SYSTEM or PUBLIC definition (might be null).public void appendDocumentStart(java.io.Writer writer, java.lang.String encoding)
writer
- The writer that receives the outputencoding
- A valid encoding name or null to omit the attributepublic void appendDocumentStart(java.io.Writer writer, java.lang.String encoding, boolean isStandalone)
writer
- The writer that receives the outputencoding
- A valid encoding name or null to omit the attributeisStandalone
- If true the standalone="yes" attribute will be addedpublic void appendXslStylesheetPI(java.io.Writer writer, java.lang.String xslFilename)
writer
- The writer that receives the outputxslFilename
- The name of an XSL file to refer topublic void appendStylesheetPI(java.io.Writer writer, java.lang.String attributes)
writer
- The writer that receives the outputattributes
- The attributes for this instructionpublic void appendStylesheetPI(java.io.Writer writer, java.util.Map<java.lang.String,java.lang.String> attributes)
writer
- The writer that receives the outputattributes
- The attributes for this instructionpublic void appendStylesheetPI(java.io.Writer writer, NamedTextList attributes)
writer
- The writer that receives the outputattributes
- The attributes for this instructionpublic void appendDocumentType(java.io.Writer writer, java.lang.String rootTagName, java.lang.String dtdURL)
writer
- The writer that receives the output (must not be null)rootTagName
- The name of the document's root tag (must not be null)dtdURL
- The url to locate the document's DTD (must not be null)public void appendDocumentType(java.io.Writer writer, java.lang.String rootTagName, java.lang.String schemaName, java.lang.String dtdURL)
writer
- The writer that receives the output (must not be null)rootTagName
- The name of the document's root tag (must not be null)schemaName
- The logical name of the schema (e.g. "-//W3C//DTD XHTML 1.0 Strict//EN").
This parameter may be null or blank which means SYSTEM will be used rather than PUBLIC.dtdURL
- The URL to locate the document's DTD (must not be null)public void appendSIXElement(Element element, java.io.Writer writer)
element
- Usually the root element of an XML treewriter
- The writer that will receive the outputpublic void appendDOM(org.w3c.dom.Document document, java.io.Writer writer)
document
- A valid DOM treewriter
- The writer that will receive the outputpublic void appendDOMElement(org.w3c.dom.Element element, java.io.Writer writer)
element
- A valid DOM tree elementwriter
- The writer that will receive the outputprotected void writeQuoted(java.io.Writer writer, java.lang.String text) throws java.io.IOException
java.io.IOException
protected char getQuoteChar()
protected DOMTreeXMLReader newXMLReader()
protected boolean getUsingDoubleQuotes()
protected void setUsingDoubleQuotes(boolean newValue)
protected StringUtil str()