Class DOMWrappingWriter
- java.lang.Object
-
- org.codehaus.stax2.ri.dom.DOMWrappingWriter
-
- All Implemented Interfaces:
javax.xml.stream.XMLStreamWriter,TypedXMLStreamWriter,Validatable,XMLStreamWriter2
public abstract class DOMWrappingWriter extends java.lang.Object implements XMLStreamWriter2
This is an adapter class that partially implementsXMLStreamWriteras a facade on top of a DOM document or Node, allowing one to basically construct DOM trees via Stax API. It is meant to serve as basis for a full implementation.Note that the implementation is only to be used with
javax.xml.transform.dom.DOMResult. It can however be used for both full documents, and single element root fragments, depending on what node is passed as the argument.One more implementation note: much code is identical to one used by
Stax2WriterAdapter. Alas it is hard to reuse it without cut'n pasting.- Since:
- 3.0
- Author:
- Tatu Saloranta
-
-
Field Summary
Fields Modifier and Type Field Description protected org.w3c.dom.DocumentmDocumentWe need a reference to the document hosting nodes to be able to create new nodesprotected java.lang.StringmEncodingThis member variable is to keep information about encoding that seems to be used for the document (or fragment) to output, if known.protected booleanmNsAwareprotected javax.xml.namespace.NamespaceContextmNsContextIf we are being given info about existing bindings, it'll come as a NamespaceContext.protected booleanmNsRepairingprotected SimpleValueEncodermValueEncoderEncoding of typed values is used the standard encoder included in RI.
-
Constructor Summary
Constructors Modifier Constructor Description protectedDOMWrappingWriter(org.w3c.dom.Node treeRoot, boolean nsAware, boolean nsRepairing)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidappendLeaf(org.w3c.dom.Node n)voidclose()voidcloseCompletely()Method similar toXMLStreamWriter.close(), except that this method also does close the underlying output destination (stream) if it has not yet been closed.voidcopyEventFromReader(XMLStreamReader2 r, boolean preserveEventData)Method that essentially copies event that the specified reader has just read.voidflush()java.lang.StringgetEncoding()Method that can be called to get information about encoding that this writer is using (or at least claims is using).XMLStreamLocation2getLocation()Method that should return current output location, if the writer keeps track of it; null if it does not.abstract javax.xml.namespace.NamespaceContextgetNamespaceContext()abstract java.lang.StringgetPrefix(java.lang.String uri)abstract java.lang.ObjectgetProperty(java.lang.String name)protected SimpleValueEncodergetValueEncoder()abstract booleanisPropertySupported(java.lang.String name)Method similar toXMLOutputFactory.isPropertySupported(java.lang.String), used to determine whether a property is supported by the Writer instance.protected voidreportUnsupported(java.lang.String operName)protected java.lang.StringserializeQNameValue(javax.xml.namespace.QName name)Method called to serialize given qualified name into valid String serialization, taking into account existing namespace bindings.abstract voidsetDefaultNamespace(java.lang.String uri)voidsetNamespaceContext(javax.xml.namespace.NamespaceContext context)abstract voidsetPrefix(java.lang.String prefix, java.lang.String uri)abstract booleansetProperty(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 matchingXMLOutputFactory2instance.ValidationProblemHandlersetValidationProblemHandler(ValidationProblemHandler h)Method that application can call to define a custom handler for validation problems encountered during validation process.XMLValidatorstopValidatingAgainst(XMLValidationSchema schema)Method that can be called by application to stop validating output against a schema, for whichValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)was called earlier.XMLValidatorstopValidatingAgainst(XMLValidator validator)Method that can be called by application to stop validating output using specified validator.protected static voidthrowOutputError(java.lang.String msg)protected static voidthrowOutputError(java.lang.String format, java.lang.Object arg)XMLValidatorvalidateAgainst(XMLValidationSchema schema)Method that will construct aXMLValidatorinstance 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 toValidatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema).abstract voidwriteAttribute(java.lang.String localName, java.lang.String value)abstract voidwriteAttribute(java.lang.String nsURI, java.lang.String localName, java.lang.String value)abstract voidwriteAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.lang.String value)voidwriteBinary(byte[] value, int from, int length)Write binary content as base64 encoded characters to the output.voidwriteBinary(Base64Variant v, byte[] value, int from, int length)voidwriteBinaryAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, byte[] value)Write a byte array attribute.voidwriteBinaryAttribute(Base64Variant v, java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, byte[] value)voidwriteBoolean(boolean value)Write a boolean value to the output as textual element content.voidwriteBooleanAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, boolean value)Write a boolean value to the output as attribute value.voidwriteCData(char[] text, int start, int len)voidwriteCData(java.lang.String data)voidwriteCharacters(char[] text, int start, int len)voidwriteCharacters(java.lang.String text)voidwriteComment(java.lang.String data)voidwriteDecimal(java.math.BigDecimal value)Write a decimal value to the output as textual element content.voidwriteDecimalAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.math.BigDecimal value)abstract voidwriteDefaultNamespace(java.lang.String nsURI)voidwriteDouble(double value)Write a double value to the output as textual element content.voidwriteDoubleArray(double[] value, int from, int length)voidwriteDoubleArrayAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, double[] value)voidwriteDoubleAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, double value)voidwriteDTD(java.lang.String dtd)abstract voidwriteDTD(java.lang.String rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset)abstract voidwriteEmptyElement(java.lang.String localName)abstract voidwriteEmptyElement(java.lang.String nsURI, java.lang.String localName)abstract voidwriteEmptyElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI)abstract voidwriteEndDocument()voidwriteEntityRef(java.lang.String name)voidwriteFloat(float value)Write a float value to the output as textual element content.voidwriteFloatArray(float[] value, int from, int length)voidwriteFloatArrayAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, float[] value)voidwriteFloatAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, float value)voidwriteFullEndElement()Method similar toXMLStreamWriter.writeEndElement(), but that will always write the full end element, instead of empty element.voidwriteInt(int value)Write an int value to the output as textual element content.voidwriteIntArray(int[] value, int from, int length)Write int array to the output.voidwriteIntArrayAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, int[] value)Write int array attribute.voidwriteIntAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, int value)Write an integer value to the output as attribute value.voidwriteInteger(java.math.BigInteger value)voidwriteIntegerAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.math.BigInteger value)voidwriteLong(long value)Write a long value to the output as textual element content.voidwriteLongArray(long[] value, int from, int length)voidwriteLongArrayAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, long[] value)voidwriteLongAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, long value)Write an long value to the output as attribute value.voidwriteProcessingInstruction(java.lang.String target)voidwriteProcessingInstruction(java.lang.String target, java.lang.String data)voidwriteQName(javax.xml.namespace.QName name)voidwriteQNameAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, javax.xml.namespace.QName name)voidwriteRaw(char[] text, int offset, int length)Method that writes specified content as is, without encoding or deciphering it in any way.voidwriteRaw(java.lang.String text)Method that writes specified content as is, without encoding or deciphering it in any way.voidwriteRaw(java.lang.String text, int start, int offset)Method that writes specified content as is, without encoding or deciphering it in any way.voidwriteSpace(char[] text, int start, int len)Method that can be called to write whitespace-only content.voidwriteSpace(java.lang.String text)Method that can be called to write whitespace-only content.voidwriteStartDocument()voidwriteStartDocument(java.lang.String version)voidwriteStartDocument(java.lang.String encoding, java.lang.String version)voidwriteStartDocument(java.lang.String version, java.lang.String encoding, boolean standAlone)
-
-
-
Field Detail
-
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 NamespaceContext.
-
mDocument
protected final org.w3c.dom.Document mDocument
We need a reference to the document hosting nodes to be able to create new nodes
-
mValueEncoder
protected SimpleValueEncoder mValueEncoder
Encoding of typed values is used the standard encoder included in RI.
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfacejavax.xml.stream.XMLStreamWriter
-
flush
public void flush()
- Specified by:
flushin interfacejavax.xml.stream.XMLStreamWriter
-
getNamespaceContext
public abstract javax.xml.namespace.NamespaceContext getNamespaceContext()
- Specified by:
getNamespaceContextin interfacejavax.xml.stream.XMLStreamWriter
-
getPrefix
public abstract java.lang.String getPrefix(java.lang.String uri)
- Specified by:
getPrefixin interfacejavax.xml.stream.XMLStreamWriter
-
getProperty
public abstract java.lang.Object getProperty(java.lang.String name)
- Specified by:
getPropertyin interfacejavax.xml.stream.XMLStreamWriter
-
setDefaultNamespace
public abstract void setDefaultNamespace(java.lang.String uri)
- Specified by:
setDefaultNamespacein interfacejavax.xml.stream.XMLStreamWriter
-
setNamespaceContext
public void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
- Specified by:
setNamespaceContextin interfacejavax.xml.stream.XMLStreamWriter
-
setPrefix
public abstract void setPrefix(java.lang.String prefix, java.lang.String uri) throws javax.xml.stream.XMLStreamException- Specified by:
setPrefixin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeAttribute
public abstract void writeAttribute(java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException- Specified by:
writeAttributein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeAttribute
public abstract void writeAttribute(java.lang.String nsURI, java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException- Specified by:
writeAttributein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeAttribute
public abstract 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:
writeAttributein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeCData
public void writeCData(java.lang.String data) throws javax.xml.stream.XMLStreamException- Specified by:
writeCDatain interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeCharacters
public void writeCharacters(char[] text, int start, int len) throws javax.xml.stream.XMLStreamException- Specified by:
writeCharactersin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeCharacters
public void writeCharacters(java.lang.String text) throws javax.xml.stream.XMLStreamException- Specified by:
writeCharactersin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeComment
public void writeComment(java.lang.String data) throws javax.xml.stream.XMLStreamException- Specified by:
writeCommentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDefaultNamespace
public abstract void writeDefaultNamespace(java.lang.String nsURI) throws javax.xml.stream.XMLStreamException- Specified by:
writeDefaultNamespacein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDTD
public void writeDTD(java.lang.String dtd) throws javax.xml.stream.XMLStreamException- Specified by:
writeDTDin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(java.lang.String localName) throws javax.xml.stream.XMLStreamException- Specified by:
writeEmptyElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(java.lang.String nsURI, java.lang.String localName) throws javax.xml.stream.XMLStreamException- Specified by:
writeEmptyElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI) throws javax.xml.stream.XMLStreamException- Specified by:
writeEmptyElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEndDocument
public abstract void writeEndDocument() throws javax.xml.stream.XMLStreamException- Specified by:
writeEndDocumentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEntityRef
public void writeEntityRef(java.lang.String name) throws javax.xml.stream.XMLStreamException- Specified by:
writeEntityRefin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(java.lang.String target) throws javax.xml.stream.XMLStreamException- Specified by:
writeProcessingInstructionin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(java.lang.String target, java.lang.String data) throws javax.xml.stream.XMLStreamException- Specified by:
writeProcessingInstructionin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument() throws javax.xml.stream.XMLStreamException- Specified by:
writeStartDocumentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument(java.lang.String version) throws javax.xml.stream.XMLStreamException- Specified by:
writeStartDocumentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument(java.lang.String encoding, java.lang.String version) throws javax.xml.stream.XMLStreamException- Specified by:
writeStartDocumentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
getLocation
public XMLStreamLocation2 getLocation()
Description copied from interface:XMLStreamWriter2Method that should return current output location, if the writer keeps track of it; null if it does not.- Specified by:
getLocationin interfaceXMLStreamWriter2
-
getEncoding
public java.lang.String getEncoding()
Description copied from interface:XMLStreamWriter2Method 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):- Passed to one of factory methods of
XMLOutputFactory - Passed to
writeStartDocumentmethod (explicitly or implicity; latter in cases where defaults are imposed by Stax specification)
- Specified by:
getEncodingin interfaceXMLStreamWriter2
- Passed to one of factory methods of
-
isPropertySupported
public abstract boolean isPropertySupported(java.lang.String name)
Description copied from interface:XMLStreamWriter2Method similar toXMLOutputFactory.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:
isPropertySupportedin interfaceXMLStreamWriter2
-
setProperty
public abstract boolean setProperty(java.lang.String name, java.lang.Object value)Description copied from interface:XMLStreamWriter2Method that can be used to set per-writer properties; a subset of properties one can set via matchingXMLOutputFactory2instance. Exactly which methods are mutable is implementation specific.- Specified by:
setPropertyin interfaceXMLStreamWriter2- Parameters:
name- Name of the property to setvalue- Value to set property to.- Returns:
- True, if the specified property was succesfully set to specified value; false if its value was not changed
-
writeCData
public void writeCData(char[] text, int start, int len) throws javax.xml.stream.XMLStreamException- Specified by:
writeCDatain interfaceXMLStreamWriter2- Throws:
javax.xml.stream.XMLStreamException
-
writeDTD
public abstract 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:
writeDTDin interfaceXMLStreamWriter2- Throws:
javax.xml.stream.XMLStreamException
-
writeFullEndElement
public void writeFullEndElement() throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:XMLStreamWriter2Method similar toXMLStreamWriter.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:
writeFullEndElementin interfaceXMLStreamWriter2- Throws:
javax.xml.stream.XMLStreamException
-
writeSpace
public void writeSpace(char[] text, int start, int len) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:XMLStreamWriter2Method 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:
writeSpacein interfaceXMLStreamWriter2- Throws:
javax.xml.stream.XMLStreamException
-
writeSpace
public void writeSpace(java.lang.String text) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:XMLStreamWriter2Method 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:
writeSpacein interfaceXMLStreamWriter2- 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:
writeStartDocumentin interfaceXMLStreamWriter2- Throws:
javax.xml.stream.XMLStreamException
-
validateAgainst
public XMLValidator validateAgainst(XMLValidationSchema schema) throws javax.xml.stream.XMLStreamException
Description copied from interface:ValidatableMethod that will construct aXMLValidatorinstance 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 toValidatable.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:
validateAgainstin interfaceValidatable- 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:ValidatableMethod that can be called by application to stop validating output against a schema, for whichValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)was called earlier.- Specified by:
stopValidatingAgainstin interfaceValidatable- 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:ValidatableMethod 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 toValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema).Note: the specified validator is compared for identity with validators in use, not for equality.
- Specified by:
stopValidatingAgainstin interfaceValidatable- 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:ValidatableMethod that application can call to define a custom handler for validation problems encountered during validation process.- Specified by:
setValidationProblemHandlerin interfaceValidatable- 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
-
writeRaw
public void writeRaw(java.lang.String text) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:XMLStreamWriter2Method 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:
writeRawin interfaceXMLStreamWriter2- Throws:
javax.xml.stream.XMLStreamException
-
writeRaw
public void writeRaw(java.lang.String text, int start, int offset) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:XMLStreamWriter2Method 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:
writeRawin interfaceXMLStreamWriter2- Throws:
javax.xml.stream.XMLStreamException
-
writeRaw
public void writeRaw(char[] text, int offset, int length) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:XMLStreamWriter2Method 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:
writeRawin interfaceXMLStreamWriter2- Throws:
javax.xml.stream.XMLStreamException
-
copyEventFromReader
public void copyEventFromReader(XMLStreamReader2 r, boolean preserveEventData) throws javax.xml.stream.XMLStreamException
Description copied from interface:XMLStreamWriter2Method 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:
copyEventFromReaderin interfaceXMLStreamWriter2- Parameters:
r- Reader to use for accessing event to copypreserveEventData- 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
-
closeCompletely
public void closeCompletely()
Description copied from interface:XMLStreamWriter2Method similar toXMLStreamWriter.close(), except that this method also does close the underlying output destination (stream) if it has not yet been closed. It is specifically necessary to call this method if the parsing ends in an exception to ensure that the output destination does get properly closed, even if the stream writer would otherwise close it (as is the case for destinations it manages where calling application has no access)- Specified by:
closeCompletelyin interfaceXMLStreamWriter2
-
writeBoolean
public void writeBoolean(boolean value) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite 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:
writeBooleanin interfaceTypedXMLStreamWriter- Parameters:
value- The boolean value to write.- Throws:
javax.xml.stream.XMLStreamException
-
writeInt
public void writeInt(int value) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite 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:
writeIntin interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeLong
public void writeLong(long value) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite a long value to the output as textual element content. The lexical representation of content is defined by the XML Schema long data type.- Specified by:
writeLongin interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeFloat
public void writeFloat(float value) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite a float value to the output as textual element content. The lexical representation of content is defined by the XML Schema float data type.- Specified by:
writeFloatin interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDouble
public void writeDouble(double value) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite a double value to the output as textual element content. The lexical representation of content is defined by the XML Schema double data type.- Specified by:
writeDoublein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeInteger
public void writeInteger(java.math.BigInteger value) throws javax.xml.stream.XMLStreamException- Specified by:
writeIntegerin interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDecimal
public void writeDecimal(java.math.BigDecimal value) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite a decimal value to the output as textual element content. The lexical representation of content is defined by the XML Schema decimal data type.- Specified by:
writeDecimalin interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeQName
public void writeQName(javax.xml.namespace.QName name) throws javax.xml.stream.XMLStreamException- Specified by:
writeQNamein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeIntArray
public void writeIntArray(int[] value, int from, int length) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite int array to the output. The lexical representation of a int array is defined by the following XML schema type:
<xs:simpleType name="intArray"> <xs:list itemType="xs:int"/> </xs:simpleType>whose lexical space is a list of space-separated ints. This method can be called multiple times to write the array in chunks.- Specified by:
writeIntArrayin interfaceTypedXMLStreamWriter- Parameters:
value- The array from which to write the ints.from- The index in the array from which writing starts.length- The number of ints to write.- Throws:
javax.xml.stream.XMLStreamException
-
writeLongArray
public void writeLongArray(long[] value, int from, int length) throws javax.xml.stream.XMLStreamException- Specified by:
writeLongArrayin interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeFloatArray
public void writeFloatArray(float[] value, int from, int length) throws javax.xml.stream.XMLStreamException- Specified by:
writeFloatArrayin interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDoubleArray
public void writeDoubleArray(double[] value, int from, int length) throws javax.xml.stream.XMLStreamException- Specified by:
writeDoubleArrayin interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeBinary
public void writeBinary(byte[] value, int from, int length) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite binary content as base64 encoded characters to the output. The lexical representation of a byte array is defined by the XML Schema base64Binary data type. This method can be called multiple times to write the array in chunks; but if so, callers should write output in chunks divisible by 3 (natural atomic unit of base64 output, which avoids padding) to maximize interoperability.
Note: base64 variant defaults to
Base64Variants.MIME.- Specified by:
writeBinaryin interfaceTypedXMLStreamWriter- Parameters:
value- The array from which to write the bytes.from- The index in the array from which writing starts.length- The number of bytes to write.- Throws:
javax.xml.stream.XMLStreamException
-
writeBinary
public void writeBinary(Base64Variant v, byte[] value, int from, int length) throws javax.xml.stream.XMLStreamException
- Specified by:
writeBinaryin interfaceTypedXMLStreamWriter- 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.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite 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:
writeBooleanAttributein interfaceTypedXMLStreamWriter- Parameters:
prefix- The attribute's prefix. Null or "" if no prefix is to be usednsURI- The attribute's URI (can be either null or empty String for "no namespace")localName- The attribute's local namevalue- 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.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite 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:
writeIntAttributein interfaceTypedXMLStreamWriter- Parameters:
prefix- The attribute's prefix. Null or "" if no prefix is to be usednsURI- The attribute's URI (can be either null or empty String for "no namespace")localName- The attribute's local namevalue- 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.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite 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:
writeLongAttributein interfaceTypedXMLStreamWriter- Parameters:
prefix- The attribute's prefix. Null or "" if no prefix is to be usednsURI- The attribute's URI (can be either null or empty String for "no namespace")localName- The attribute's local namevalue- The long value to write.- Throws:
javax.xml.stream.XMLStreamException
-
writeFloatAttribute
public void writeFloatAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, float value) throws javax.xml.stream.XMLStreamException- Specified by:
writeFloatAttributein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDoubleAttribute
public void writeDoubleAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, double value) throws javax.xml.stream.XMLStreamException- Specified by:
writeDoubleAttributein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeIntegerAttribute
public void writeIntegerAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.math.BigInteger value) throws javax.xml.stream.XMLStreamException- Specified by:
writeIntegerAttributein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDecimalAttribute
public void writeDecimalAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.math.BigDecimal value) throws javax.xml.stream.XMLStreamException- Specified by:
writeDecimalAttributein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeQNameAttribute
public void writeQNameAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, javax.xml.namespace.QName name) throws javax.xml.stream.XMLStreamException- Specified by:
writeQNameAttributein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeIntArrayAttribute
public void writeIntArrayAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, int[] value) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite int array attribute. The lexical representation of a int array is defined by the following XML schema type:
<xs:simpleType name="intArray"> <xs:list itemType="xs:int"/> </xs:simpleType>whose lexical space is a list of space-separated ints.- Specified by:
writeIntArrayAttributein interfaceTypedXMLStreamWriter- Parameters:
prefix- The attribute's prefix.nsURI- The attribute's URI.localName- The attribute's local name.value- The array from which to write the ints.- Throws:
javax.xml.stream.XMLStreamException
-
writeLongArrayAttribute
public void writeLongArrayAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, long[] value) throws javax.xml.stream.XMLStreamException- Specified by:
writeLongArrayAttributein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeFloatArrayAttribute
public void writeFloatArrayAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, float[] value) throws javax.xml.stream.XMLStreamException- Specified by:
writeFloatArrayAttributein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDoubleArrayAttribute
public void writeDoubleArrayAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, double[] value) throws javax.xml.stream.XMLStreamException- Specified by:
writeDoubleArrayAttributein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeBinaryAttribute
public void writeBinaryAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, byte[] value) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:TypedXMLStreamWriterWrite a byte array attribute. The lexical representation of a byte array is defined by the XML Schema base64Binary data type.
Note: base64 variant defaults to
Base64Variants.MIME.- Specified by:
writeBinaryAttributein interfaceTypedXMLStreamWriter- Parameters:
prefix- The attribute's prefix.nsURI- The attribute's URI.localName- The attribute's local name.value- The array from which to write the bytes.- Throws:
javax.xml.stream.XMLStreamException
-
writeBinaryAttribute
public void writeBinaryAttribute(Base64Variant v, java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, byte[] value) throws javax.xml.stream.XMLStreamException
- Specified by:
writeBinaryAttributein interfaceTypedXMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
appendLeaf
protected abstract void appendLeaf(org.w3c.dom.Node n) throws java.lang.IllegalStateException- Throws:
java.lang.IllegalStateException
-
serializeQNameValue
protected java.lang.String serializeQNameValue(javax.xml.namespace.QName name) throws javax.xml.stream.XMLStreamExceptionMethod called to serialize given qualified name into valid String serialization, taking into account existing namespace bindings.- Throws:
javax.xml.stream.XMLStreamException
-
getValueEncoder
protected SimpleValueEncoder getValueEncoder()
-
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
-
reportUnsupported
protected void reportUnsupported(java.lang.String operName)
-
-