com.ctc.wstx.dom
Class DOMWrappingWriter

java.lang.Object
  extended by com.ctc.wstx.dom.DOMWrappingWriter
All Implemented Interfaces:
javax.xml.stream.XMLStreamWriter, TypedXMLStreamWriter, Validatable, XMLStreamWriter2

public class DOMWrappingWriter
extends java.lang.Object
implements XMLStreamWriter2

This is an adapter class that allows building a DOM tree using XMLStreamWriter interface.

Note that the implementation is only to be used for use with javax.xml.transform.dom.DOMResult.

Some notes regarding missing/incomplete functionality:

Author:
Tatu Saloranta, Dan Diephouse

Field Summary
protected static java.lang.String ERR_NSDECL_WRONG_STATE
           
protected  java.lang.String mAutomaticNsPrefix
           
protected  int[] mAutoNsSeq
          for NsRepairing mode
protected  WriterConfig mConfig
           
protected  DOMOutputElement mCurrElem
          This element is the current context element, under which all other nodes are added, until matching end element is output.
protected  org.w3c.dom.Document mDocument
          We need a reference to the document hosting nodes to be able to create new nodes
protected  java.lang.String mEncoding
          This member variable is to keep information about encoding that seems to be used for the document (or fragment) to output, if known.
protected  boolean mNsAware
           
protected  javax.xml.namespace.NamespaceContext mNsContext
          If we are being given info about existing bindings, it'll come as a NamespaceContet.
protected  boolean mNsRepairing
           
protected  DOMOutputElement mOpenElement
          This element is non-null right after a call to either writeStartElement and writeEmptyElement, and can be used to add attributes and namespace declarations.
protected  java.lang.String mSuggestedDefNs
           
protected static java.lang.String sPrefixXml
           
protected static java.lang.String sPrefixXmlns
           
 
Method Summary
protected  void appendLeaf(org.w3c.dom.Node n)
           
 void close()
           
 void copyEventFromReader(XMLStreamReader2 r, boolean preserveEventData)
          Method that essentially copies event that the specified reader has just read.
static DOMWrappingWriter createFrom(WriterConfig cfg, javax.xml.transform.dom.DOMResult dst)
           
protected  void createStartElem(java.lang.String nsURI, java.lang.String prefix, java.lang.String localName, boolean isEmpty)
           
protected  java.lang.String findElemPrefix(java.lang.String nsURI, DOMOutputElement elem)
          Method called to find an existing prefix for the given namespace, if any exists in the scope.
protected  java.lang.String findOrCreateAttrPrefix(java.lang.String suggPrefix, java.lang.String nsURI, DOMOutputElement elem)
          Method called to somehow find a prefix for given namespace, to be used for a new start element; either use an existing one, or generate a new one.
 void flush()
           
protected  java.lang.String generateElemPrefix(java.lang.String suggPrefix, java.lang.String nsURI, DOMOutputElement elem)
          Method called after findElemPrefix(java.lang.String, com.ctc.wstx.dom.DOMOutputElement) has returned null, to create and bind a namespace mapping for specified namespace.
 java.lang.String getEncoding()
          Method that can be called to get information about encoding that this writer is using (or at least claims is using).
 XMLStreamLocation2 getLocation()
          Method that should return current output location, if the writer keeps track of it; null if it does not.
 javax.xml.namespace.NamespaceContext getNamespaceContext()
           
 java.lang.String getPrefix(java.lang.String uri)
           
 java.lang.Object getProperty(java.lang.String name)
           
 boolean isPropertySupported(java.lang.String name)
          Method similar to XMLOutputFactory.isPropertySupported(java.lang.String), used to determine whether a property is supported by the Writer instance.
protected  void outputAttribute(java.lang.String nsURI, java.lang.String prefix, java.lang.String localName, java.lang.String value)
           
 void setDefaultNamespace(java.lang.String uri)
           
 void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
           
 void setPrefix(java.lang.String prefix, java.lang.String uri)
           
 boolean setProperty(java.lang.String name, java.lang.Object value)
          Method that can be used to set per-writer properties; a subset of properties one can set via matching XMLOutputFactory2 instance.
 ValidationProblemHandler setValidationProblemHandler(ValidationProblemHandler h)
          Method that application can call to define a custom handler for validation problems encountered during validation process.
 XMLValidator stopValidatingAgainst(XMLValidationSchema schema)
          Method that can be called by application to stop validating output against a schema, for which Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema) was called earlier.
 XMLValidator stopValidatingAgainst(XMLValidator validator)
          Method that can be called by application to stop validating output using specified validator.
protected static void throwOutputError(java.lang.String msg)
           
protected static void throwOutputError(java.lang.String format, java.lang.Object arg)
           
 XMLValidator validateAgainst(XMLValidationSchema schema)
          Method that will construct a XMLValidator instance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call to Validatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema).
 void writeAttribute(java.lang.String localName, java.lang.String value)
           
 void writeAttribute(java.lang.String nsURI, java.lang.String localName, java.lang.String value)
           
 void writeAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.lang.String value)
           
 void writeBoolean(boolean value)
          Write a boolean value to the output as textual element content.
 void writeBooleanAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, boolean value)
          Write a boolean value to the output as attribute value.
 void writeCData(char[] text, int start, int len)
           
 void writeCData(java.lang.String data)
           
 void writeCharacters(char[] text, int start, int len)
           
 void writeCharacters(java.lang.String text)
           
 void writeComment(java.lang.String data)
           
 void writeDefaultNamespace(java.lang.String nsURI)
           
 void writeDTD(java.lang.String dtd)
           
 void writeDTD(java.lang.String rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset)
           
 void writeEmptyElement(java.lang.String localName)
           
 void writeEmptyElement(java.lang.String nsURI, java.lang.String localName)
           
 void writeEmptyElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI)
           
 void writeEndDocument()
           
 void writeEndElement()
           
 void writeEntityRef(java.lang.String name)
           
 void writeFullEndElement()
          Method similar to XMLStreamWriter.writeEndElement(), but that will always write the full end element, instead of empty element.
 void writeInt(int value)
          Write an int value to the output as textual element content.
 void writeIntAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, int value)
          Write an integer value to the output as attribute value.
 void writeLong(long value)
          Write an int value to the output as textual element content.
 void writeLongAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, long value)
          Write an long value to the output as attribute value.
 void writeNamespace(java.lang.String prefix, java.lang.String nsURI)
           
 void writeProcessingInstruction(java.lang.String target)
           
 void writeProcessingInstruction(java.lang.String target, java.lang.String data)
           
 void writeRaw(char[] text, int offset, int length)
          Method that writes specified content as is, without encoding or deciphering it in any way.
 void writeRaw(java.lang.String text)
          Method that writes specified content as is, without encoding or deciphering it in any way.
 void writeRaw(java.lang.String text, int start, int offset)
          Method that writes specified content as is, without encoding or deciphering it in any way.
 void writeSpace(char[] text, int start, int len)
          Method that can be called to write whitespace-only content.
 void writeSpace(java.lang.String text)
          Method that can be called to write whitespace-only content.
 void writeStartDocument()
           
 void writeStartDocument(java.lang.String version)
           
 void writeStartDocument(java.lang.String encoding, java.lang.String version)
           
 void writeStartDocument(java.lang.String version, java.lang.String encoding, boolean standAlone)
           
 void writeStartElement(java.lang.String localName)
           
 void writeStartElement(java.lang.String nsURI, java.lang.String localName)
           
 void writeStartElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sPrefixXml

protected static final java.lang.String sPrefixXml

sPrefixXmlns

protected static final java.lang.String sPrefixXmlns

ERR_NSDECL_WRONG_STATE

protected static final java.lang.String ERR_NSDECL_WRONG_STATE
See Also:
Constant Field Values

mConfig

protected final WriterConfig mConfig

mNsAware

protected final boolean mNsAware

mNsRepairing

protected final boolean mNsRepairing

mEncoding

protected java.lang.String mEncoding
This member variable is to keep information about encoding that seems to be used for the document (or fragment) to output, if known.


mNsContext

protected javax.xml.namespace.NamespaceContext mNsContext
If we are being given info about existing bindings, it'll come as a NamespaceContet.


mDocument

protected final org.w3c.dom.Document mDocument
We need a reference to the document hosting nodes to be able to create new nodes


mCurrElem

protected DOMOutputElement mCurrElem
This element is the current context element, under which all other nodes are added, until matching end element is output. Null outside of the main element tree.

Note: explicit empty element (written using writeEmptyElement) will never become current element.


mOpenElement

protected DOMOutputElement mOpenElement
This element is non-null right after a call to either writeStartElement and writeEmptyElement, and can be used to add attributes and namespace declarations.

Note: while this is often the same as mCurrElem, it's not always. Specifically, an empty element (written explicitly using writeEmptyElement) will become open element but NOT current element. Conversely, regular elements will remain current element when non elements are written (text, comments, PI), but not the open element.


mAutoNsSeq

protected int[] mAutoNsSeq
for NsRepairing mode


mSuggestedDefNs

protected java.lang.String mSuggestedDefNs

mAutomaticNsPrefix

protected java.lang.String mAutomaticNsPrefix
Method Detail

createFrom

public static DOMWrappingWriter createFrom(WriterConfig cfg,
                                           javax.xml.transform.dom.DOMResult dst)
                                    throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

close

public void close()
Specified by:
close in interface javax.xml.stream.XMLStreamWriter

flush

public void flush()
Specified by:
flush in interface javax.xml.stream.XMLStreamWriter

getNamespaceContext

public javax.xml.namespace.NamespaceContext getNamespaceContext()
Specified by:
getNamespaceContext in interface javax.xml.stream.XMLStreamWriter

getPrefix

public java.lang.String getPrefix(java.lang.String uri)
Specified by:
getPrefix in interface javax.xml.stream.XMLStreamWriter

getProperty

public java.lang.Object getProperty(java.lang.String name)
Specified by:
getProperty in interface javax.xml.stream.XMLStreamWriter

setDefaultNamespace

public void setDefaultNamespace(java.lang.String uri)
Specified by:
setDefaultNamespace in interface javax.xml.stream.XMLStreamWriter

setNamespaceContext

public void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
Specified by:
setNamespaceContext in interface javax.xml.stream.XMLStreamWriter

setPrefix

public void setPrefix(java.lang.String prefix,
                      java.lang.String uri)
               throws javax.xml.stream.XMLStreamException
Specified by:
setPrefix in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeAttribute

public void writeAttribute(java.lang.String localName,
                           java.lang.String value)
                    throws javax.xml.stream.XMLStreamException
Specified by:
writeAttribute in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeAttribute

public void writeAttribute(java.lang.String nsURI,
                           java.lang.String localName,
                           java.lang.String value)
                    throws javax.xml.stream.XMLStreamException
Specified by:
writeAttribute in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeAttribute

public void writeAttribute(java.lang.String prefix,
                           java.lang.String nsURI,
                           java.lang.String localName,
                           java.lang.String value)
                    throws javax.xml.stream.XMLStreamException
Specified by:
writeAttribute in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeCData

public void writeCData(java.lang.String data)
Specified by:
writeCData in interface javax.xml.stream.XMLStreamWriter

writeCharacters

public void writeCharacters(char[] text,
                            int start,
                            int len)
Specified by:
writeCharacters in interface javax.xml.stream.XMLStreamWriter

writeCharacters

public void writeCharacters(java.lang.String text)
Specified by:
writeCharacters in interface javax.xml.stream.XMLStreamWriter

writeComment

public void writeComment(java.lang.String data)
Specified by:
writeComment in interface javax.xml.stream.XMLStreamWriter

writeDefaultNamespace

public void writeDefaultNamespace(java.lang.String nsURI)
Specified by:
writeDefaultNamespace in interface javax.xml.stream.XMLStreamWriter

writeDTD

public void writeDTD(java.lang.String dtd)
Specified by:
writeDTD in interface javax.xml.stream.XMLStreamWriter

writeEmptyElement

public void writeEmptyElement(java.lang.String localName)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeEmptyElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeEmptyElement

public void writeEmptyElement(java.lang.String nsURI,
                              java.lang.String localName)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeEmptyElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeEmptyElement

public void writeEmptyElement(java.lang.String prefix,
                              java.lang.String localName,
                              java.lang.String nsURI)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeEmptyElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeEndDocument

public void writeEndDocument()
Specified by:
writeEndDocument in interface javax.xml.stream.XMLStreamWriter

writeEndElement

public void writeEndElement()
Specified by:
writeEndElement in interface javax.xml.stream.XMLStreamWriter

writeEntityRef

public void writeEntityRef(java.lang.String name)
Specified by:
writeEntityRef in interface javax.xml.stream.XMLStreamWriter

writeNamespace

public void writeNamespace(java.lang.String prefix,
                           java.lang.String nsURI)
                    throws javax.xml.stream.XMLStreamException
Specified by:
writeNamespace in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeProcessingInstruction

public void writeProcessingInstruction(java.lang.String target)
Specified by:
writeProcessingInstruction in interface javax.xml.stream.XMLStreamWriter

writeProcessingInstruction

public void writeProcessingInstruction(java.lang.String target,
                                       java.lang.String data)
Specified by:
writeProcessingInstruction in interface javax.xml.stream.XMLStreamWriter

writeSpace

public void writeSpace(char[] text,
                       int start,
                       int len)
Description copied from interface: XMLStreamWriter2
Method that can be called to write whitespace-only content. If so, it is to be written as is (with no escaping), and does not contain non-whitespace characters (writer may validate this, and throw an exception if it does).

This method is useful for things like outputting indentation.

Specified by:
writeSpace in interface XMLStreamWriter2

writeSpace

public void writeSpace(java.lang.String text)
Description copied from interface: XMLStreamWriter2
Method that can be called to write whitespace-only content. If so, it is to be written as is (with no escaping), and does not contain non-whitespace characters (writer may validate this, and throw an exception if it does).

This method is useful for things like outputting indentation.

Specified by:
writeSpace in interface XMLStreamWriter2

writeStartDocument

public void writeStartDocument()
Specified by:
writeStartDocument in interface javax.xml.stream.XMLStreamWriter

writeStartDocument

public void writeStartDocument(java.lang.String version)
Specified by:
writeStartDocument in interface javax.xml.stream.XMLStreamWriter

writeStartDocument

public void writeStartDocument(java.lang.String encoding,
                               java.lang.String version)
Specified by:
writeStartDocument in interface javax.xml.stream.XMLStreamWriter

writeStartElement

public void writeStartElement(java.lang.String localName)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeStartElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeStartElement

public void writeStartElement(java.lang.String nsURI,
                              java.lang.String localName)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeStartElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeStartElement

public void writeStartElement(java.lang.String prefix,
                              java.lang.String localName,
                              java.lang.String nsURI)
                       throws javax.xml.stream.XMLStreamException
Specified by:
writeStartElement in interface javax.xml.stream.XMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeBoolean

public void writeBoolean(boolean value)
                  throws javax.xml.stream.XMLStreamException
Description copied from interface: TypedXMLStreamWriter
Write a boolean value to the output as textual element content. The lexical representation of content is defined by the XML Schema boolean data type.

Specified by:
writeBoolean in interface TypedXMLStreamWriter
Parameters:
value - The boolean value to write.
Throws:
javax.xml.stream.XMLStreamException

writeInt

public void writeInt(int value)
              throws javax.xml.stream.XMLStreamException
Description copied from interface: TypedXMLStreamWriter
Write an int value to the output as textual element content. The lexical representation of content is defined by the XML Schema integer data type.

Specified by:
writeInt in interface TypedXMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeLong

public void writeLong(long value)
               throws javax.xml.stream.XMLStreamException
Description copied from interface: TypedXMLStreamWriter
Write an int value to the output as textual element content. The lexical representation of content is defined by the XML Schema integer data type.

Specified by:
writeLong in interface TypedXMLStreamWriter
Throws:
javax.xml.stream.XMLStreamException

writeBooleanAttribute

public void writeBooleanAttribute(java.lang.String prefix,
                                  java.lang.String nsURI,
                                  java.lang.String localName,
                                  boolean value)
                           throws javax.xml.stream.XMLStreamException
Description copied from interface: TypedXMLStreamWriter
Write a boolean value to the output as attribute value. The lexical representation of content is defined by the XML Schema boolean data type.

Specified by:
writeBooleanAttribute in interface TypedXMLStreamWriter
Parameters:
prefix - The attribute's prefix. Null or "" if no prefix is to be used
nsURI - The attribute's URI (can be either null or empty String for "no namespace")
localName - The attribute's local name
value - The boolean value to write.
Throws:
javax.xml.stream.XMLStreamException

writeIntAttribute

public void writeIntAttribute(java.lang.String prefix,
                              java.lang.String nsURI,
                              java.lang.String localName,
                              int value)
                       throws javax.xml.stream.XMLStreamException
Description copied from interface: TypedXMLStreamWriter
Write an integer value to the output as attribute value. The lexical representation of content is defined by the XML Schema integer data type.

Specified by:
writeIntAttribute in interface TypedXMLStreamWriter
Parameters:
prefix - The attribute's prefix. Null or "" if no prefix is to be used
nsURI - The attribute's URI (can be either null or empty String for "no namespace")
localName - The attribute's local name
value - The integer value to write.
Throws:
javax.xml.stream.XMLStreamException

writeLongAttribute

public void writeLongAttribute(java.lang.String prefix,
                               java.lang.String nsURI,
                               java.lang.String localName,
                               long value)
                        throws javax.xml.stream.XMLStreamException
Description copied from interface: TypedXMLStreamWriter
Write an long value to the output as attribute value. The lexical representation of content is defined by the XML Schema long data type.

Specified by:
writeLongAttribute in interface TypedXMLStreamWriter
Parameters:
prefix - The attribute's prefix. Null or "" if no prefix is to be used
nsURI - The attribute's URI (can be either null or empty String for "no namespace")
localName - The attribute's local name
value - The long value to write.
Throws:
javax.xml.stream.XMLStreamException

isPropertySupported

public boolean isPropertySupported(java.lang.String name)
Description copied from interface: XMLStreamWriter2
Method similar to XMLOutputFactory.isPropertySupported(java.lang.String), used to determine whether a property is supported by the Writer instance. This means that this method may return false for some properties that the output factory does support: specifically, it should only return true if the value is mutable on per-instance basis. False means that either the property is not recognized, or is not mutable via writer instance.

Specified by:
isPropertySupported in interface XMLStreamWriter2

setProperty

public boolean setProperty(java.lang.String name,
                           java.lang.Object value)
Description copied from interface: XMLStreamWriter2
Method that can be used to set per-writer properties; a subset of properties one can set via matching XMLOutputFactory2 instance. Exactly which methods are mutable is implementation specific.

Specified by:
setProperty in interface XMLStreamWriter2
Parameters:
name - Name of the property to set
value - Value to set property to.
Returns:
True, if the specified property was succesfully set to specified value; false if its value was not changed

validateAgainst

public XMLValidator validateAgainst(XMLValidationSchema schema)
                             throws javax.xml.stream.XMLStreamException
Description copied from interface: Validatable
Method that will construct a XMLValidator instance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call to Validatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema).

Note that while this method can be called at any point in output processing, validator instances are not required to be able to handle addition at other points than right before outputting the root element.

Specified by:
validateAgainst in interface Validatable
Returns:
Validator instance constructed, if validator was added, or null if a validator for the schema has already been constructed.
Throws:
javax.xml.stream.XMLStreamException

stopValidatingAgainst

public XMLValidator stopValidatingAgainst(XMLValidationSchema schema)
                                   throws javax.xml.stream.XMLStreamException
Description copied from interface: Validatable
Method that can be called by application to stop validating output against a schema, for which Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema) was called earlier.

Specified by:
stopValidatingAgainst in interface Validatable
Returns:
Validator instance created from the schema that was removed, if one was in use; null if no such schema in use.
Throws:
javax.xml.stream.XMLStreamException

stopValidatingAgainst

public XMLValidator stopValidatingAgainst(XMLValidator validator)
                                   throws javax.xml.stream.XMLStreamException
Description copied from interface: Validatable
Method that can be called by application to stop validating output using specified validator. The validator passed should be an earlier return value for a call to Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema).

Note: the specified validator is compared for identity with validators in use, not for equality.

Specified by:
stopValidatingAgainst in interface Validatable
Returns:
Validator instance found (ie. argument validator) if it was being used for validating current document; null if not.
Throws:
javax.xml.stream.XMLStreamException

setValidationProblemHandler

public ValidationProblemHandler setValidationProblemHandler(ValidationProblemHandler h)
Description copied from interface: Validatable
Method that application can call to define a custom handler for validation problems encountered during validation process.

Specified by:
setValidationProblemHandler in interface Validatable
Parameters:
h - Handler to install, if non null; if null, indicates that the default (implementation-specific) handling should be used
Returns:
Previously set validation problem handler, if any; null if none was set

getLocation

public XMLStreamLocation2 getLocation()
Description copied from interface: XMLStreamWriter2
Method that should return current output location, if the writer keeps track of it; null if it does not.

Specified by:
getLocation in interface XMLStreamWriter2

getEncoding

public java.lang.String getEncoding()
Description copied from interface: XMLStreamWriter2
Method that can be called to get information about encoding that this writer is using (or at least claims is using). That is, it returns name of encoding specified when (in order of priority):

Specified by:
getEncoding in interface XMLStreamWriter2

writeCData

public void writeCData(char[] text,
                       int start,
                       int len)
                throws javax.xml.stream.XMLStreamException
Specified by:
writeCData in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeDTD

public void writeDTD(java.lang.String rootName,
                     java.lang.String systemId,
                     java.lang.String publicId,
                     java.lang.String internalSubset)
              throws javax.xml.stream.XMLStreamException
Specified by:
writeDTD in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeFullEndElement

public void writeFullEndElement()
                         throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamWriter2
Method similar to XMLStreamWriter.writeEndElement(), but that will always write the full end element, instead of empty element. This only matters for cases where the element itself has no content, and if writer is allowed to write empty elements when it encounters such start/end element write pairs.

Specified by:
writeFullEndElement in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeStartDocument

public void writeStartDocument(java.lang.String version,
                               java.lang.String encoding,
                               boolean standAlone)
                        throws javax.xml.stream.XMLStreamException
Specified by:
writeStartDocument in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeRaw

public void writeRaw(java.lang.String text)
              throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamWriter2
Method that writes specified content as is, without encoding or deciphering it in any way. It will not update state of the writer (except by possibly flushing output of previous writes, like finishing a start element), nor be validated in any way. As such, care must be taken, if this method is used.

Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.

NOTE: since text to be written may be anything, including markup, it can not be reliably validated. Because of this, validator(s) attached to the writer will NOT be informed about writes.

Specified by:
writeRaw in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeRaw

public void writeRaw(java.lang.String text,
                     int start,
                     int offset)
              throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamWriter2
Method that writes specified content as is, without encoding or deciphering it in any way. It will not update state of the writer (except by possibly flushing output of previous writes, like finishing a start element), nor be validated in any way. As such, care must be taken, if this method is used.

Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.

NOTE: since text to be written may be anything, including markup, it can not be reliably validated. Because of this, validator(s) attached to the writer will NOT be informed about writes.

Specified by:
writeRaw in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeRaw

public void writeRaw(char[] text,
                     int offset,
                     int length)
              throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamWriter2
Method that writes specified content as is, without encoding or deciphering it in any way. It will not update state of the writer (except by possibly flushing output of previous writes, like finishing a start element), nor be validated in any way. As such, care must be taken, if this method is used.

Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.

NOTE: since text to be written may be anything, including markup, it can not be reliably validated. Because of this, validator(s) attached to the writer will NOT be informed about writes.

Specified by:
writeRaw in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

copyEventFromReader

public void copyEventFromReader(XMLStreamReader2 r,
                                boolean preserveEventData)
                         throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamWriter2
Method that essentially copies event that the specified reader has just read. This can be both more convenient (no need to worry about details) and more efficient than separately calling access methods of the reader and write methods of the writer, since writer may know more about reader than the application (and may be able to use non-public methods)

Specified by:
copyEventFromReader in interface XMLStreamWriter2
Parameters:
r - Reader to use for accessing event to copy
preserveEventData - If true, writer is not allowed to change the state of the reader (so that all the data associated with the current event has to be preserved); if false, writer is allowed to use methods that may cause some data to be discarded. Setting this to false may improve the performance, since it may allow full no-copy streaming of data, especially textual contents.
Throws:
javax.xml.stream.XMLStreamException

appendLeaf

protected void appendLeaf(org.w3c.dom.Node n)
                   throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

createStartElem

protected void createStartElem(java.lang.String nsURI,
                               java.lang.String prefix,
                               java.lang.String localName,
                               boolean isEmpty)
                        throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

outputAttribute

protected void outputAttribute(java.lang.String nsURI,
                               java.lang.String prefix,
                               java.lang.String localName,
                               java.lang.String value)
                        throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

findElemPrefix

protected final java.lang.String findElemPrefix(java.lang.String nsURI,
                                                DOMOutputElement elem)
                                         throws javax.xml.stream.XMLStreamException
Method called to find an existing prefix for the given namespace, if any exists in the scope. If one is found, it's returned (including "" for the current default namespace); if not, null is returned.

Parameters:
nsURI - URI of namespace for which we need a prefix
Throws:
javax.xml.stream.XMLStreamException

generateElemPrefix

protected final java.lang.String generateElemPrefix(java.lang.String suggPrefix,
                                                    java.lang.String nsURI,
                                                    DOMOutputElement elem)
                                             throws javax.xml.stream.XMLStreamException
Method called after findElemPrefix(java.lang.String, com.ctc.wstx.dom.DOMOutputElement) has returned null, to create and bind a namespace mapping for specified namespace.

Throws:
javax.xml.stream.XMLStreamException

findOrCreateAttrPrefix

protected final java.lang.String findOrCreateAttrPrefix(java.lang.String suggPrefix,
                                                        java.lang.String nsURI,
                                                        DOMOutputElement elem)
                                                 throws javax.xml.stream.XMLStreamException
Method called to somehow find a prefix for given namespace, to be used for a new start element; either use an existing one, or generate a new one. If a new mapping needs to be generated, it will also be automatically bound, and necessary namespace declaration output.

Parameters:
suggPrefix - Suggested prefix to bind, if any; may be null to indicate "no preference"
nsURI - URI of namespace for which we need a prefix
elem - Currently open start element, on which the attribute will be added.
Throws:
javax.xml.stream.XMLStreamException

throwOutputError

protected static void throwOutputError(java.lang.String msg)
                                throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

throwOutputError

protected static void throwOutputError(java.lang.String format,
                                       java.lang.Object arg)
                                throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException