public class StaxXmlWriter extends Object implements XMLStreamWriter
XmlWriter that implements
the XMLStreamWriter interface from the StAX API.| Constructor and Description |
|---|
StaxXmlWriter(XmlWriter writer) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close this writer and free any resources associated with the writer.
|
void |
flush()
Write any cached data to the underlying output mechanism.
|
NamespaceContext |
getNamespaceContext()
Get the current namespace context.
|
String |
getPrefix(String namespaceUri)
Get the prefix for the XML Namespace URI.
|
Object |
getProperty(String name)
Get the value of a feature/property from the underlying implementation.
|
void |
setDefaultNamespace(String namespaceUri)
Bind the namespace URI to the default namespace.
|
void |
setNamespaceContext(NamespaceContext namespaceContext)
Set the current namespace context.
|
void |
setPrefix(String prefix,
String namespaceUri)
Set the prefix for the XML Namespace URI.
|
void |
writeAttribute(String name,
String value)
Writes an attribute to the current start tag.
|
void |
writeAttribute(String namespaceUri,
String name,
String value)
Writes an attribute to the current start tag.
|
void |
writeAttribute(String prefix,
String namespaceUri,
String name,
String value)
Writes an attribute to the current start tag.
|
void |
writeCData(String text)
Write the contents in a CDATA section.
|
void |
writeCharacters(char[] buffer,
int offset,
int length)
Write a portion of the character buffer to the outpu, escaping special
characters.
|
void |
writeCharacters(String text)
Write the text string to the output, escaping special characters.
|
void |
writeComment(String comment)
Write an XML comment.
|
void |
writeDefaultNamespace(String namespaceUri)
Writes a default namespace to the output stream.
|
void |
writeDTD(String dtd)
Write a DTD section.
|
void |
writeEmptyElement(String name)
Writes an empty tag to the output.
|
void |
writeEmptyElement(String namespaceUri,
String name)
Writes an empty tag to the output.
|
void |
writeEmptyElement(String prefix,
String name,
String namespaceUri)
Writes an empty tag to the output.
|
void |
writeEndDocument()
End a document, closing all tags and flushing the output.
|
void |
writeEndElement()
Writes an end tag to the output.
|
void |
writeEntityRef(String name)
Write the entity reference with the specified text.
|
void |
writeNamespace(String prefix,
String namespaceUri)
Writes a namespace to the output stream.
|
void |
writeProcessingInstruction(String target)
Write an XML processing instruction.
|
void |
writeProcessingInstruction(String target,
String value)
Write an XML processing instruction.
|
void |
writeStartDocument()
Start a document with an XML Declaration.
|
void |
writeStartDocument(String encoding)
Start a document with an XML Declaration.
|
void |
writeStartDocument(String encoding,
String version)
Start a document with an XML Declaration.
|
void |
writeStartElement(String name)
Writes a start tag to the output.
|
void |
writeStartElement(String namespaceUri,
String name)
Writes a start tag to the output.
|
void |
writeStartElement(String prefix,
String name,
String namespaceUri)
Writes a start tag to the output.
|
public StaxXmlWriter(XmlWriter writer)
writer - public void close()
throws XMLStreamException
Close this writer and free any resources associated with the writer. Note: this underlying writer closes the stream so this method breaks from the StAX specification which says it must not close te underlying output stream.
close in interface XMLStreamWriterXMLStreamException - If an exception writing the XML occurs.public void flush()
throws XMLStreamException
flush in interface XMLStreamWriterXMLStreamException - If an exception writing the XML occurs.public NamespaceContext getNamespaceContext()
getNamespaceContext in interface XMLStreamWriterpublic String getPrefix(String namespaceUri) throws XMLStreamException
getPrefix in interface XMLStreamWriternamespaceUri - The XML Namespace URI.XMLStreamException - If there was an exception getting the prefix.public Object getProperty(String name)
getProperty in interface XMLStreamWritername - The name of the property, may not be null.public void setDefaultNamespace(String namespaceUri) throws XMLStreamException
setDefaultNamespace in interface XMLStreamWriternamespaceUri - The XML Namespace URI.XMLStreamException - If there was an exception setting the prefix.public void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException
setNamespaceContext in interface XMLStreamWriternamespaceContext - The namespace context.XMLStreamException - If there was an error setting the context.public void setPrefix(String prefix, String namespaceUri) throws XMLStreamException
setPrefix in interface XMLStreamWriterprefix - The prefix.namespaceUri - The XML Namespace URI.XMLStreamException - If there was an exception setting the prefix.public void writeAttribute(String name, String value) throws XMLStreamException
writeAttribute in interface XMLStreamWritername - The local name of the element.value - The value of the attributeXMLStreamException - If an exception writing the XML occurs.public void writeAttribute(String namespaceUri, String name, String value) throws XMLStreamException
writeAttribute in interface XMLStreamWritername - The local name of the element.namespaceUri - The XML Namespace URI of the element.value - The value of the attributeXMLStreamException - If an exception writing the XML occurs.public void writeAttribute(String prefix, String namespaceUri, String name, String value) throws XMLStreamException
writeAttribute in interface XMLStreamWriterprefix - The XML Namespace prefix of the element.name - The local name of the element.namespaceUri - The XML Namespace URI of the element.value - The value of the attributeXMLStreamException - If an exception writing the XML occurs.public void writeCData(String text) throws XMLStreamException
writeCData in interface XMLStreamWritertext - The text to wrap in a CDATA sectionXMLStreamException - If there was a problem writing the textpublic void writeCharacters(char[] buffer,
int offset,
int length)
throws XMLStreamException
writeCharacters in interface XMLStreamWriterbuffer - The buffer to write.offset - The starting offset in the buffer.length - The number of characters to write.XMLStreamException - If there was a problem writing the text.public void writeCharacters(String text) throws XMLStreamException
writeCharacters in interface XMLStreamWritertext - The text to writeXMLStreamException - If there was a problem writing the textpublic void writeComment(String comment) throws XMLStreamException
writeComment in interface XMLStreamWritercomment - The comment to writeXMLStreamException - If there was a problem writing the commentpublic void writeDefaultNamespace(String namespaceUri) throws XMLStreamException
writeDefaultNamespace in interface XMLStreamWriternamespaceUri - The XML Namespace URI.XMLStreamException - If there was a problem writing the namespace.public void writeDTD(String dtd) throws XMLStreamException
writeDTD in interface XMLStreamWriterdtd - The DTD to be writtenXMLStreamException - If there was a problem writing the declarationpublic void writeEmptyElement(String name) throws XMLStreamException
writeEmptyElement in interface XMLStreamWritername - The local name of the element.XMLStreamException - If an exception writing the XML occurs.public void writeEmptyElement(String namespaceUri, String name) throws XMLStreamException
writeEmptyElement in interface XMLStreamWritername - The local name of the element.namespaceUri - The XML Namespace URI of the element.XMLStreamException - If an exception writing the XML occurs.public void writeEmptyElement(String prefix, String name, String namespaceUri) throws XMLStreamException
writeEmptyElement in interface XMLStreamWriterprefix - The XML Namespace prefix of the element.name - The local name of the element.namespaceUri - The XML Namespace URI of the element.XMLStreamException - If an exception writing the XML occurs.public void writeEndDocument()
throws XMLStreamException
writeEndDocument in interface XMLStreamWriterXMLStreamException - If an exception writing the XML occurs.public void writeEndElement()
throws XMLStreamException
writeEndElement in interface XMLStreamWriterXMLStreamException - If an exception writing the XML occurs.public void writeEntityRef(String name) throws XMLStreamException
writeEntityRef in interface XMLStreamWritername - The name of the entityXMLStreamException - If there was a problem writing the entitypublic void writeNamespace(String prefix, String namespaceUri) throws XMLStreamException
writeNamespace in interface XMLStreamWriterprefix - The prefix.namespaceUri - The XML Namespace URI.XMLStreamException - If there was a problem writing the namespace.public void writeProcessingInstruction(String target) throws XMLStreamException
writeProcessingInstruction in interface XMLStreamWritertarget - The PI Target (must not be xml)XMLStreamException - If there was a problem writing the commentpublic void writeProcessingInstruction(String target, String value) throws XMLStreamException
writeProcessingInstruction in interface XMLStreamWritertarget - The PI Target (must not be xml)value - The value of the processing instructionXMLStreamException - If there was a problem writing the commentpublic void writeStartDocument()
throws XMLStreamException
writeStartDocument in interface XMLStreamWriterXMLStreamException - If there was a problem writing the XML
Declaration.public void writeStartDocument(String encoding) throws XMLStreamException
writeStartDocument in interface XMLStreamWriterencoding - The encoding for the XML declaration.XMLStreamException - If there was a problem writing the XML
Declaration.public void writeStartDocument(String encoding, String version) throws XMLStreamException
writeStartDocument in interface XMLStreamWriterencoding - The encoding for the XML declaration.version - XMLStreamException - If there was a problem writing the XML
Declaration.public void writeStartElement(String name) throws XMLStreamException
writeStartElement in interface XMLStreamWritername - The local name of the element.XMLStreamException - If an exception writing the XML occurs.public void writeStartElement(String namespaceUri, String name) throws XMLStreamException
writeStartElement in interface XMLStreamWriternamespaceUri - The XML Namespace URI of the element.name - The local name of the element.XMLStreamException - If an exception writing the XML occurs.public void writeStartElement(String prefix, String name, String namespaceUri) throws XMLStreamException
writeStartElement in interface XMLStreamWriterprefix - The XML Namespace prefix of the element.name - The local name of the element.namespaceUri - The XML Namespace URI of the element.XMLStreamException - If an exception writing the XML occurs.Copyright © 2015 Revolution Systems Inc.. All rights reserved.