javanet.staxutils.io
Class XMLWriterUtils

java.lang.Object
  extended byjavanet.staxutils.io.XMLWriterUtils

public final class XMLWriterUtils
extends java.lang.Object

Set of utility methods useful when writing XML.

Version:
$Revision: 1.6 $
Author:
Christian Niles

Method Summary
static void writeAttribute(Attribute attr, java.io.Writer writer)
          Writes an Attribute to the provided stream.
static void writeAttribute(Attribute attr, XMLStreamWriter writer)
          Writes an Attribute to the provided stream.
static void writeAttribute(QName name, java.lang.String value, java.io.Writer writer)
          Writes an attribute to the provided stream.
static void writeCData(char[] data, int start, int length, java.io.Writer writer)
          Writes a Characters to the provided stream.
static void writeCData(java.lang.String text, java.io.Writer writer)
          Writes a Characters to the provided stream.
static void writeCharacters(char[] data, int start, int length, java.io.Writer writer)
          Writes a chunk of encoded text to the provided stream.
static void writeCharacters(Characters chars, java.io.Writer writer)
          Writes a Characters to the provided stream.
static void writeCharacters(Characters chars, XMLStreamWriter writer)
          Writes a Characters to the provided stream.
static void writeCharacters(java.lang.CharSequence text, java.io.Writer writer)
          Writes a chunk of encoded text to the provided stream.
static void writeComment(Comment comment, java.io.Writer writer)
          Writes a Comment to the provided stream.
static void writeComment(Comment comment, XMLStreamWriter writer)
          Writes a Comment to the provided stream.
static void writeComment(java.lang.String comment, java.io.Writer writer)
          Writes a comment to the provided stream.
static void writeDTD(DTD dtd, java.io.Writer writer)
          Writes a DTD to the provided stream.
static void writeDTD(DTD dtd, XMLStreamWriter writer)
          Writes a DTD to the provided stream.
static void writeDTD(java.lang.String dtd, java.io.Writer writer)
          Writes a dtd to the provided stream.
static void writeEncodedCharacter(char c, java.io.Writer writer)
          Encodes the provided character if needed, and writes it to an output stream.
static void writeEncodedQuotedValue(java.lang.String value, java.io.Writer writer)
          Encodes the given value and writes it to the provided stream, wrapping it in the appropriate quote character.
static void writeEncodedText(char[] text, int start, int len, java.io.Writer writer)
           
static void writeEncodedText(java.lang.CharSequence text, java.io.Writer writer)
          Encodes the provided text and writes it to the provided stream.
static void writeEncodedValue(java.lang.String value, char quoteChar, java.io.Writer writer)
          Encodes the given value, and writes it to the stream, but does not actually wrap the value in the quote character.
static void writeEndDocument(EndDocument end, java.io.Writer writer)
          Writes an EndDocument to the provided stream.
static void writeEndDocument(EndDocument end, XMLStreamWriter writer)
          Writes an EndDocument to the provided stream.
static void writeEndDocument(java.io.Writer writer)
          Writes an document ending to the provided stream.
static void writeEndElement(EndElement end, java.io.Writer writer)
          Writes an EndElement to the provided stream.
static void writeEndElement(EndElement end, XMLStreamWriter writer)
          Writes an EndElement to the provided stream.
static void writeEndElement(QName name, java.io.Writer writer)
          Writes an element end tag to the provided stream.
static void writeEntityDeclaration(EntityDeclaration declaration, java.io.Writer writer)
          Writes an EntityDeclaration to the stream.
static void writeEntityDeclaration(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notation, java.io.Writer writer)
          Writes an external entity declaration to the stream.
static void writeEntityDeclaration(java.lang.String name, java.lang.String text, java.lang.String notation, java.io.Writer writer)
          Writes an internal entity declaration to the stream.
static void writeEntityReference(EntityReference entityRef, java.io.Writer writer)
          Writes an EntityReference to the provided stream.
static void writeEntityReference(EntityReference entityRef, XMLStreamWriter writer)
          Writes an EntityReference to the provided stream.
static void writeEntityReference(java.lang.String entityRef, java.io.Writer writer)
          Writes an entity reference to the provided stream.
static void writeEvent(XMLEvent event, java.io.Writer writer)
          Writes the given event to the provided Writer.
static void writeEvent(XMLEvent event, XMLStreamWriter writer)
          Writes the given event to the provided XMLStreamWriter.
static void writeNamespace(Namespace ns, java.io.Writer writer)
          Writes a Namespace to the provided stream.
static void writeNamespace(Namespace ns, XMLStreamWriter writer)
          Writes a Namespace to the provided stream.
static void writeNamespace(java.lang.String prefix, java.lang.String uri, java.io.Writer writer)
          Writes a Namespace to the provided stream.
static void writeNotationDeclaration(NotationDeclaration declaration, java.io.Writer writer)
          Writes a NotationDeclaration to the stream.
static void writeNotationDeclaration(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.io.Writer writer)
          Writes a notation declaration to the stream.
static void writeProcessingInstruction(ProcessingInstruction procInst, java.io.Writer writer)
          Writes a ProcessingInstruction to the provided stream.
static void writeProcessingInstruction(ProcessingInstruction procInst, XMLStreamWriter writer)
          Writes a ProcessingInstruction to the provided stream.
static void writeProcessingInstruction(java.lang.String target, java.lang.String data, java.io.Writer writer)
          Writes a ProcessingInstruction to the provided stream.
static void writeQName(QName name, java.io.Writer writer)
          Writes a qualified name to the provided stream.
static void writeQName(java.lang.String prefix, java.lang.String localPart, java.io.Writer writer)
          Writes a qualified name to the provided stream.
static void writeQuotedValue(java.lang.String value, java.io.Writer writer)
          Writes a quoted version of the given value, automatically determining the appropriate quote character.
static void writeStartDocument(StartDocument start, java.io.Writer writer)
          Writes a StartDocument to the provided stream.
static void writeStartDocument(StartDocument start, XMLStreamWriter writer)
          Writes a StartDocument to the provided stream.
static void writeStartDocument(java.lang.String version, java.lang.String encoding, boolean standalone, java.io.Writer writer)
          Writes an XML declaration to the provided stream.
static void writeStartDocument(java.lang.String version, java.lang.String encoding, java.lang.String standalone, java.io.Writer writer)
          Writes an XML declaration to the provided stream.
static void writeStartDocument(java.lang.String version, java.lang.String encoding, java.io.Writer writer)
          Writes an XML declaration to the provided stream.
static void writeStartDocument(java.lang.String version, java.io.Writer writer)
          Writes an XML declaration to the provided stream.
static void writeStartDocument(java.io.Writer writer)
          Writes a default XML declaration to the provided stream.
static void writeStartElement(QName name, java.util.Iterator attributes, java.util.Iterator namespaces, boolean empty, java.io.Writer writer)
          Writes a start tag and any associated namespaces and attributes to the provided stream.
static void writeStartElement(QName name, java.util.Iterator attributes, java.util.Iterator namespaces, java.io.Writer writer)
          Writes a start tag and any associated namespaces and attributes to the provided stream.
static void writeStartElement(QName name, java.util.Map attributes, java.util.Map namespaces, boolean empty, java.io.Writer writer)
          Writes a start tag and any associated namespaces and attributes to the provided stream.
static void writeStartElement(StartElement start, boolean empty, java.io.Writer writer)
          Writes a StartElement event to the provided stream.
static void writeStartElement(StartElement start, boolean empty, XMLStreamWriter writer)
          Writes a StartElement event to the provided stream.
static void writeStartElement(StartElement start, java.io.Writer writer)
          Writes a StartElement event to the provided stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

writeQuotedValue

public static final void writeQuotedValue(java.lang.String value,
                                          java.io.Writer writer)
                                   throws java.io.IOException
Writes a quoted version of the given value, automatically determining the appropriate quote character. The value will not be encoded before being written. This method is useful when writing quoted DTD values, such as system IDs.

Parameters:
value - The value to quote and output.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEncodedQuotedValue

public static final void writeEncodedQuotedValue(java.lang.String value,
                                                 java.io.Writer writer)
                                          throws java.io.IOException
Encodes the given value and writes it to the provided stream, wrapping it in the appropriate quote character. This method is useful when writing attribute values, and entity replacement text.

Parameters:
value - The value to encode, quote, and output.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEncodedValue

public static final void writeEncodedValue(java.lang.String value,
                                           char quoteChar,
                                           java.io.Writer writer)
                                    throws java.io.IOException
Encodes the given value, and writes it to the stream, but does not actually wrap the value in the quote character. The provided quote character is used to determine whether a character must be encoded or not.

Parameters:
value - The value to encode and output.
quoteChar - The quote character; used to determine which characters need to be encoded.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEncodedText

public static final void writeEncodedText(java.lang.CharSequence text,
                                          java.io.Writer writer)
                                   throws java.io.IOException
Encodes the provided text and writes it to the provided stream. This method is useful when writing character data, such as element text or CData sections, and will not encode single or double quotes.

Parameters:
text - The text to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEncodedText

public static final void writeEncodedText(char[] text,
                                          int start,
                                          int len,
                                          java.io.Writer writer)
                                   throws java.io.IOException
Throws:
java.io.IOException

writeEncodedCharacter

public static final void writeEncodedCharacter(char c,
                                               java.io.Writer writer)
                                        throws java.io.IOException
Encodes the provided character if needed, and writes it to an output stream.

Parameters:
c - The character to encode and output.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeQName

public static final void writeQName(QName name,
                                    java.io.Writer writer)
                             throws java.io.IOException
Writes a qualified name to the provided stream.

Parameters:
name - The name to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeQName

public static final void writeQName(java.lang.String prefix,
                                    java.lang.String localPart,
                                    java.io.Writer writer)
                             throws java.io.IOException
Writes a qualified name to the provided stream.

Parameters:
prefix - The prefix, or null
localPart - The local part.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEvent

public static final void writeEvent(XMLEvent event,
                                    java.io.Writer writer)
                             throws java.io.IOException,
                                    XMLStreamException
Writes the given event to the provided Writer. This method will delegate the actual task of writing to the stream to the appropriate overloaded method.

Parameters:
event - The event to write.
writer - The destination XML stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.
XMLStreamException - If the event is a StartElement and an error occurs writing the Namespace or Attribute events.
java.lang.IllegalArgumentException - If the event is an unknown type.

writeStartDocument

public static final void writeStartDocument(StartDocument start,
                                            java.io.Writer writer)
                                     throws java.io.IOException
Writes a StartDocument to the provided stream.

Parameters:
start - The StartDocument to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeStartDocument

public static final void writeStartDocument(java.io.Writer writer)
                                     throws java.io.IOException
Writes a default XML declaration to the provided stream.

Parameters:
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeStartDocument

public static final void writeStartDocument(java.lang.String version,
                                            java.io.Writer writer)
                                     throws java.io.IOException
Writes an XML declaration to the provided stream.

Parameters:
version - The xml version definition.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeStartDocument

public static final void writeStartDocument(java.lang.String version,
                                            java.lang.String encoding,
                                            java.io.Writer writer)
                                     throws java.io.IOException
Writes an XML declaration to the provided stream.

Parameters:
version - The xml version definition.
encoding - The document encoding, or null
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeStartDocument

public static final void writeStartDocument(java.lang.String version,
                                            java.lang.String encoding,
                                            boolean standalone,
                                            java.io.Writer writer)
                                     throws java.io.IOException
Writes an XML declaration to the provided stream.

Parameters:
version - The xml version definition.
encoding - The document encoding, or null
standalone - The standalone definition
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeStartDocument

public static final void writeStartDocument(java.lang.String version,
                                            java.lang.String encoding,
                                            java.lang.String standalone,
                                            java.io.Writer writer)
                                     throws java.io.IOException
Writes an XML declaration to the provided stream.

Parameters:
version - The xml version definition.
encoding - The document encoding, or null
standalone - The standalone definition, or null
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEndDocument

public static final void writeEndDocument(EndDocument end,
                                          java.io.Writer writer)
                                   throws java.io.IOException
Writes an EndDocument to the provided stream.

Parameters:
end - The EndDocument to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEndDocument

public static final void writeEndDocument(java.io.Writer writer)
                                   throws java.io.IOException
Writes an document ending to the provided stream.

Parameters:
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeStartElement

public static final void writeStartElement(StartElement start,
                                           java.io.Writer writer)
                                    throws java.io.IOException,
                                           XMLStreamException
Writes a StartElement event to the provided stream.

Parameters:
start - The StartElement event to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.
XMLStreamException - If an error occurs writing any namespaces or attribute events.

writeStartElement

public static final void writeStartElement(StartElement start,
                                           boolean empty,
                                           java.io.Writer writer)
                                    throws java.io.IOException,
                                           XMLStreamException
Writes a StartElement event to the provided stream.

Parameters:
start - The StartElement event to write.
empty - Whether the element is empty.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.
XMLStreamException - If an error occurs writing any namespaces or attribute events.

writeStartElement

public static final void writeStartElement(QName name,
                                           java.util.Iterator attributes,
                                           java.util.Iterator namespaces,
                                           java.io.Writer writer)
                                    throws java.io.IOException,
                                           XMLStreamException
Writes a start tag and any associated namespaces and attributes to the provided stream.

Parameters:
name - The tag name.
attributes - An Attribute iterator, or null.
namespaces - A Namespace iterator, or null.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.
XMLStreamException - If an error occurs writing any namespaces or attribute events.

writeStartElement

public static final void writeStartElement(QName name,
                                           java.util.Iterator attributes,
                                           java.util.Iterator namespaces,
                                           boolean empty,
                                           java.io.Writer writer)
                                    throws java.io.IOException,
                                           XMLStreamException
Writes a start tag and any associated namespaces and attributes to the provided stream.

Parameters:
name - The tag name.
attributes - An Attribute iterator, or null.
namespaces - A Namespace iterator, or null.
empty - Whether the element is empty.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.
XMLStreamException

writeStartElement

public static final void writeStartElement(QName name,
                                           java.util.Map attributes,
                                           java.util.Map namespaces,
                                           boolean empty,
                                           java.io.Writer writer)
                                    throws java.io.IOException
Writes a start tag and any associated namespaces and attributes to the provided stream.

Parameters:
name - The tag name.
attributes - A Map of attribute values, keyed by their QNames. If no attributes are present, this may be null.
namespaces - A Map of namespace values, keyed by their prefixes. If no namespaces are present, this may be null.
empty - Whether the element is empty.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeAttribute

public static final void writeAttribute(Attribute attr,
                                        java.io.Writer writer)
                                 throws java.io.IOException
Writes an Attribute to the provided stream.

Parameters:
attr - The Attribute to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeAttribute

public static final void writeAttribute(QName name,
                                        java.lang.String value,
                                        java.io.Writer writer)
                                 throws java.io.IOException
Writes an attribute to the provided stream.

Parameters:
name - The attribute name.
value - The attribute value.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeNamespace

public static final void writeNamespace(Namespace ns,
                                        java.io.Writer writer)
                                 throws java.io.IOException
Writes a Namespace to the provided stream.

Parameters:
ns - The Namespace to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeNamespace

public static final void writeNamespace(java.lang.String prefix,
                                        java.lang.String uri,
                                        java.io.Writer writer)
                                 throws java.io.IOException
Writes a Namespace to the provided stream.

Parameters:
prefix - The namespace prefix, which may be null.
uri - The namespace uri.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEndElement

public static final void writeEndElement(EndElement end,
                                         java.io.Writer writer)
                                  throws java.io.IOException
Writes an EndElement to the provided stream.

Parameters:
end - The EndElement to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEndElement

public static final void writeEndElement(QName name,
                                         java.io.Writer writer)
                                  throws java.io.IOException
Writes an element end tag to the provided stream.

Parameters:
name - The element name.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeCharacters

public static final void writeCharacters(Characters chars,
                                         java.io.Writer writer)
                                  throws java.io.IOException
Writes a Characters to the provided stream.

Parameters:
chars - The Characters to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeCharacters

public static final void writeCharacters(java.lang.CharSequence text,
                                         java.io.Writer writer)
                                  throws java.io.IOException
Writes a chunk of encoded text to the provided stream.

Parameters:
text - The text to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeCharacters

public static final void writeCharacters(char[] data,
                                         int start,
                                         int length,
                                         java.io.Writer writer)
                                  throws java.io.IOException
Writes a chunk of encoded text to the provided stream.

Parameters:
data - A character array containing the characters.
start - The starting index into the array.
length - The number of characters to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeCData

public static final void writeCData(java.lang.String text,
                                    java.io.Writer writer)
                             throws java.io.IOException
Writes a Characters to the provided stream.

Parameters:
text - The CData text to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeCData

public static final void writeCData(char[] data,
                                    int start,
                                    int length,
                                    java.io.Writer writer)
                             throws java.io.IOException
Writes a Characters to the provided stream.

Parameters:
data - A character array containing the cdata text.
start - The starting index into the array.
length - The number of characters to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeComment

public static final void writeComment(Comment comment,
                                      java.io.Writer writer)
                               throws java.io.IOException
Writes a Comment to the provided stream.

Parameters:
comment - The Comment to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.
java.io.IOException

writeComment

public static final void writeComment(java.lang.String comment,
                                      java.io.Writer writer)
                               throws java.io.IOException
Writes a comment to the provided stream.

Parameters:
comment - The comment text.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.
java.io.IOException

writeEntityReference

public static final void writeEntityReference(EntityReference entityRef,
                                              java.io.Writer writer)
                                       throws java.io.IOException
Writes an EntityReference to the provided stream.

Parameters:
entityRef - The EntityReference to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.
java.io.IOException

writeEntityReference

public static final void writeEntityReference(java.lang.String entityRef,
                                              java.io.Writer writer)
                                       throws java.io.IOException
Writes an entity reference to the provided stream.

Parameters:
entityRef - The name of the entity reference.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.
java.io.IOException

writeEntityDeclaration

public static final void writeEntityDeclaration(EntityDeclaration declaration,
                                                java.io.Writer writer)
                                         throws java.io.IOException
Writes an EntityDeclaration to the stream.

Parameters:
declaration - The EntityDeclaration to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEntityDeclaration

public static final void writeEntityDeclaration(java.lang.String name,
                                                java.lang.String publicId,
                                                java.lang.String systemId,
                                                java.lang.String notation,
                                                java.io.Writer writer)
                                         throws java.io.IOException
Writes an external entity declaration to the stream. Either or both of the publicId and systemId parameters must be non-null.

Parameters:
name - The entity name.
publicId - The entity public ID, or null.
systemId - The entity system ID, or null.
notation - The notation name, or null.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEntityDeclaration

public static final void writeEntityDeclaration(java.lang.String name,
                                                java.lang.String text,
                                                java.lang.String notation,
                                                java.io.Writer writer)
                                         throws java.io.IOException
Writes an internal entity declaration to the stream.

Parameters:
name - The entity name.
text - The entity replacement text.
notation - The notation name, or null.
writer -
Throws:
java.io.IOException

writeNotationDeclaration

public static final void writeNotationDeclaration(NotationDeclaration declaration,
                                                  java.io.Writer writer)
                                           throws java.io.IOException
Writes a NotationDeclaration to the stream.

Parameters:
declaration - The NotationDeclaration to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeNotationDeclaration

public static final void writeNotationDeclaration(java.lang.String name,
                                                  java.lang.String publicId,
                                                  java.lang.String systemId,
                                                  java.io.Writer writer)
                                           throws java.io.IOException
Writes a notation declaration to the stream. Either or both of the publicId and systemId parameters must be non-null.

Parameters:
name - The notation name.
publicId - The entity public ID, or null.
systemId - The entity system ID, or null.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeProcessingInstruction

public static final void writeProcessingInstruction(ProcessingInstruction procInst,
                                                    java.io.Writer writer)
                                             throws java.io.IOException
Writes a ProcessingInstruction to the provided stream.

Parameters:
procInst - The ProcessingInstruction to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.
java.io.IOException

writeProcessingInstruction

public static final void writeProcessingInstruction(java.lang.String target,
                                                    java.lang.String data,
                                                    java.io.Writer writer)
                                             throws java.io.IOException
Writes a ProcessingInstruction to the provided stream.

Parameters:
target - The instruction target.
data - The instruction data, or null.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.
java.io.IOException

writeDTD

public static final void writeDTD(DTD dtd,
                                  java.io.Writer writer)
                           throws java.io.IOException
Writes a DTD to the provided stream.

Parameters:
dtd - The DTD to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeDTD

public static final void writeDTD(java.lang.String dtd,
                                  java.io.Writer writer)
                           throws java.io.IOException
Writes a dtd to the provided stream.

Parameters:
dtd - The dtd to write.
writer - The destination stream.
Throws:
java.io.IOException - If an error occurs writing to the stream.

writeEvent

public static final void writeEvent(XMLEvent event,
                                    XMLStreamWriter writer)
                             throws XMLStreamException
Writes the given event to the provided XMLStreamWriter. This method will delegate the actual task of writing to the stream to the appropriate overloaded method.

Parameters:
event - The event to write.
writer - The destination XML stream.
Throws:
XMLStreamException - If an error occurs writing the event.

writeStartElement

public static final void writeStartElement(StartElement start,
                                           boolean empty,
                                           XMLStreamWriter writer)
                                    throws XMLStreamException
Writes a StartElement event to the provided stream.

Parameters:
start - The StartElement event to write.
empty - Whether the element is empty.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeEndElement

public static final void writeEndElement(EndElement end,
                                         XMLStreamWriter writer)
                                  throws XMLStreamException
Writes an EndElement to the provided stream.

Parameters:
end - The EndElement to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeAttribute

public static final void writeAttribute(Attribute attr,
                                        XMLStreamWriter writer)
                                 throws XMLStreamException
Writes an Attribute to the provided stream.

Parameters:
attr - The Attribute to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeNamespace

public static final void writeNamespace(Namespace ns,
                                        XMLStreamWriter writer)
                                 throws XMLStreamException
Writes a Namespace to the provided stream.

Parameters:
ns - The Namespace to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeStartDocument

public static final void writeStartDocument(StartDocument start,
                                            XMLStreamWriter writer)
                                     throws XMLStreamException
Writes a StartDocument to the provided stream.

Parameters:
start - The StartDocument to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeEndDocument

public static final void writeEndDocument(EndDocument end,
                                          XMLStreamWriter writer)
                                   throws XMLStreamException
Writes an EndDocument to the provided stream.

Parameters:
end - The EndDocument to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeCharacters

public static final void writeCharacters(Characters chars,
                                         XMLStreamWriter writer)
                                  throws XMLStreamException
Writes a Characters to the provided stream.

Parameters:
chars - The Characters to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeComment

public static final void writeComment(Comment comment,
                                      XMLStreamWriter writer)
                               throws XMLStreamException
Writes a Comment to the provided stream.

Parameters:
comment - The Comment to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeEntityReference

public static final void writeEntityReference(EntityReference entityRef,
                                              XMLStreamWriter writer)
                                       throws XMLStreamException
Writes an EntityReference to the provided stream.

Parameters:
entityRef - The EntityReference to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeProcessingInstruction

public static final void writeProcessingInstruction(ProcessingInstruction procInst,
                                                    XMLStreamWriter writer)
                                             throws XMLStreamException
Writes a ProcessingInstruction to the provided stream.

Parameters:
procInst - The ProcessingInstruction to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.

writeDTD

public static final void writeDTD(DTD dtd,
                                  XMLStreamWriter writer)
                           throws XMLStreamException
Writes a DTD to the provided stream.

Parameters:
dtd - The DTD to write.
writer - The destination stream.
Throws:
XMLStreamException - If an error occurs writing to the stream.