Package org.apache.xml.serialize
Class DOMSerializerImpl
- java.lang.Object
-
- org.apache.xml.serialize.DOMSerializerImpl
-
- All Implemented Interfaces:
org.w3c.dom.DOMConfiguration,org.w3c.dom.ls.LSSerializer
public class DOMSerializerImpl extends java.lang.Object implements org.w3c.dom.ls.LSSerializer, org.w3c.dom.DOMConfigurationDeprecated.Replaced by org.apache.xml.serializer.dom3.LSSerializerImpl in Xerces 2.9.0.EXPERIMENTAL: Implemenatation of DOM Level 3 org.w3c.ls.LSSerializer by delegating serialization calls toXMLSerializer. LSSerializer provides an API for serializing (writing) a DOM document out in an XML document. The XML data is written to an output stream. During serialization of XML data, namespace fixup is done when possible as defined in DOM Level 3 Core, Appendix B.- Version:
- $Id: DOMSerializerImpl.java 944789 2010-05-16 10:06:57Z mukulg $
- Author:
- Elena Litani, IBM, Gopal Sharma, Sun Microsystems, Arun Yadav, Sun Microsystems
-
-
Field Summary
Fields Modifier and Type Field Description protected static shortCDATADeprecated.protected static shortCOMMENTSDeprecated.protected static shortDISCARDDEFAULTDeprecated.protected static shortDOM_ELEMENT_CONTENT_WHITESPACEDeprecated.protected static shortENTITIESDeprecated.protected shortfeaturesDeprecated.REVISIT: Currently we handle 3 different configurations, would be nice just have one configuration that has different recognized parameters depending if it is used in Core/LS.protected static shortINFOSETDeprecated.protected static shortNAMESPACESDeprecated.protected static shortNSDECLDeprecated.protected static shortPRETTY_PRINTDeprecated.protected static shortSPLITCDATADeprecated.protected static shortWELLFORMEDDeprecated.protected static shortXMLDECLDeprecated.
-
Constructor Summary
Constructors Constructor Description DOMSerializerImpl()Deprecated.Constructs a new LSSerializer.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanSetParameter(java.lang.String name, java.lang.Object state)Deprecated.DOM L3-EXPERIMENTAL: Check if parameter can be setorg.w3c.dom.DOMConfigurationgetDomConfig()Deprecated.org.w3c.dom.ls.LSSerializerFiltergetFilter()Deprecated.When the application provides a filter, the serializer will call out to the filter before serializing each Node.java.lang.StringgetNewLine()Deprecated.DOM L3 EXPERIMENTAL: The end-of-line sequence of characters to be used in the XML being written out.java.lang.ObjectgetParameter(java.lang.String name)Deprecated.DOM L3-EXPERIMENTAL: Getter for boolean and object parametersorg.w3c.dom.DOMStringListgetParameterNames()Deprecated.DOM Level 3 Core CR - Experimental.voidsetFilter(org.w3c.dom.ls.LSSerializerFilter filter)Deprecated.When the application provides a filter, the serializer will call out to the filter before serializing each Node.voidsetNewLine(java.lang.String newLine)Deprecated.DOM L3 EXPERIMENTAL: The end-of-line sequence of characters to be used in the XML being written out.voidsetParameter(java.lang.String name, java.lang.Object value)Deprecated.DOM L3-EXPERIMENTAL: Setter for boolean and object parametersbooleanwrite(org.w3c.dom.Node node, org.w3c.dom.ls.LSOutput destination)Deprecated.Serialize the specified node as described above in the general description of theLSSerializerinterface.java.lang.StringwriteToString(org.w3c.dom.Node wnode)Deprecated.DOM L3 EXPERIMENTAL: Serialize the specified node as described above in the description ofLSSerializer.booleanwriteToURI(org.w3c.dom.Node node, java.lang.String URI)Deprecated.Serialize the specified node as described above in the general description of theLSSerializerinterface.
-
-
-
Field Detail
-
features
protected short features
Deprecated.REVISIT: Currently we handle 3 different configurations, would be nice just have one configuration that has different recognized parameters depending if it is used in Core/LS.
-
NAMESPACES
protected static final short NAMESPACES
Deprecated.- See Also:
- Constant Field Values
-
WELLFORMED
protected static final short WELLFORMED
Deprecated.- See Also:
- Constant Field Values
-
ENTITIES
protected static final short ENTITIES
Deprecated.- See Also:
- Constant Field Values
-
CDATA
protected static final short CDATA
Deprecated.- See Also:
- Constant Field Values
-
SPLITCDATA
protected static final short SPLITCDATA
Deprecated.- See Also:
- Constant Field Values
-
COMMENTS
protected static final short COMMENTS
Deprecated.- See Also:
- Constant Field Values
-
DISCARDDEFAULT
protected static final short DISCARDDEFAULT
Deprecated.- See Also:
- Constant Field Values
-
INFOSET
protected static final short INFOSET
Deprecated.- See Also:
- Constant Field Values
-
XMLDECL
protected static final short XMLDECL
Deprecated.- See Also:
- Constant Field Values
-
NSDECL
protected static final short NSDECL
Deprecated.- See Also:
- Constant Field Values
-
DOM_ELEMENT_CONTENT_WHITESPACE
protected static final short DOM_ELEMENT_CONTENT_WHITESPACE
Deprecated.- See Also:
- Constant Field Values
-
PRETTY_PRINT
protected static final short PRETTY_PRINT
Deprecated.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DOMSerializerImpl
public DOMSerializerImpl()
Deprecated.Constructs a new LSSerializer. The constructor turns on the namespace support inXMLSerializerand initializes the following fields: fNSBinder, fLocalNSBinder, fSymbolTable, fEmptySymbol, fXmlSymbol, fXmlnsSymbol, fNamespaceCounter, fFeatures.
-
-
Method Detail
-
getDomConfig
public org.w3c.dom.DOMConfiguration getDomConfig()
Deprecated.- Specified by:
getDomConfigin interfaceorg.w3c.dom.ls.LSSerializer
-
setParameter
public void setParameter(java.lang.String name, java.lang.Object value) throws org.w3c.dom.DOMExceptionDeprecated.DOM L3-EXPERIMENTAL: Setter for boolean and object parameters- Specified by:
setParameterin interfaceorg.w3c.dom.DOMConfiguration- Throws:
org.w3c.dom.DOMException
-
canSetParameter
public boolean canSetParameter(java.lang.String name, java.lang.Object state)Deprecated.DOM L3-EXPERIMENTAL: Check if parameter can be set- Specified by:
canSetParameterin interfaceorg.w3c.dom.DOMConfiguration
-
getParameterNames
public org.w3c.dom.DOMStringList getParameterNames()
Deprecated.DOM Level 3 Core CR - Experimental. The list of the parameters supported by thisDOMConfigurationobject and for which at least one value can be set by the application. Note that this list can also contain parameter names defined outside this specification.- Specified by:
getParameterNamesin interfaceorg.w3c.dom.DOMConfiguration
-
getParameter
public java.lang.Object getParameter(java.lang.String name) throws org.w3c.dom.DOMExceptionDeprecated.DOM L3-EXPERIMENTAL: Getter for boolean and object parameters- Specified by:
getParameterin interfaceorg.w3c.dom.DOMConfiguration- Throws:
org.w3c.dom.DOMException
-
writeToString
public java.lang.String writeToString(org.w3c.dom.Node wnode) throws org.w3c.dom.DOMException, org.w3c.dom.ls.LSExceptionDeprecated.DOM L3 EXPERIMENTAL: Serialize the specified node as described above in the description ofLSSerializer. The result of serializing the node is returned as a string. Writing a Document or Entity node produces a serialized form that is well formed XML. Writing other node types produces a fragment of text in a form that is not fully defined by this document, but that should be useful to a human for debugging or diagnostic purposes.- Specified by:
writeToStringin interfaceorg.w3c.dom.ls.LSSerializer- Parameters:
wnode- The node to be written.- Returns:
- Returns the serialized data
- Throws:
org.w3c.dom.DOMException- DOMSTRING_SIZE_ERR: The resulting string is too long to fit in aDOMString.org.w3c.dom.ls.LSException- SERIALIZE_ERR: Unable to serialize the node. DOM applications should attach aDOMErrorHandlerusing the parameter "error-handler" to get details on error.
-
setNewLine
public void setNewLine(java.lang.String newLine)
Deprecated.DOM L3 EXPERIMENTAL: The end-of-line sequence of characters to be used in the XML being written out. The only permitted values are these:null- Use a default end-of-line sequence. DOM implementations should choose the default to match the usual convention for text files in the environment being used. Implementations must choose a default sequence that matches one of those allowed by 2.11 "End-of-Line Handling".
- CR
- The carriage-return character (#xD).
- CR-LF
- The carriage-return and line-feed characters (#xD #xA).
- LF
- The line-feed character (#xA).
The default value for this attribute isnull.- Specified by:
setNewLinein interfaceorg.w3c.dom.ls.LSSerializer
-
getNewLine
public java.lang.String getNewLine()
Deprecated.DOM L3 EXPERIMENTAL: The end-of-line sequence of characters to be used in the XML being written out. The only permitted values are these:null- Use a default end-of-line sequence. DOM implementations should choose the default to match the usual convention for text files in the environment being used. Implementations must choose a default sequence that matches one of those allowed by 2.11 "End-of-Line Handling".
- CR
- The carriage-return character (#xD).
- CR-LF
- The carriage-return and line-feed characters (#xD #xA).
- LF
- The line-feed character (#xA).
The default value for this attribute isnull.- Specified by:
getNewLinein interfaceorg.w3c.dom.ls.LSSerializer
-
getFilter
public org.w3c.dom.ls.LSSerializerFilter getFilter()
Deprecated.When the application provides a filter, the serializer will call out to the filter before serializing each Node. Attribute nodes are never passed to the filter. The filter implementation can choose to remove the node from the stream or to terminate the serialization early.- Specified by:
getFilterin interfaceorg.w3c.dom.ls.LSSerializer
-
setFilter
public void setFilter(org.w3c.dom.ls.LSSerializerFilter filter)
Deprecated.When the application provides a filter, the serializer will call out to the filter before serializing each Node. Attribute nodes are never passed to the filter. The filter implementation can choose to remove the node from the stream or to terminate the serialization early.- Specified by:
setFilterin interfaceorg.w3c.dom.ls.LSSerializer
-
write
public boolean write(org.w3c.dom.Node node, org.w3c.dom.ls.LSOutput destination) throws org.w3c.dom.ls.LSExceptionDeprecated.Serialize the specified node as described above in the general description of theLSSerializerinterface. The output is written to the suppliedLSOutput.
When writing to aLSOutput, the encoding is found by looking at the encoding information that is reachable through theLSOutputand the item to be written (or its owner document) in this order:-
LSOutput.encoding, -
Document.actualEncoding, -
Document.xmlEncoding.
If no encoding is reachable through the above properties, a default encoding of "UTF-8" will be used.
If the specified encoding is not supported an "unsupported-encoding" error is raised.
If no output is specified in theLSOutput, a "no-output-specified" error is raised.- Specified by:
writein interfaceorg.w3c.dom.ls.LSSerializer- Parameters:
node- The node to serialize.destination- The destination for the serialized DOM.- Returns:
- Returns
trueifnodewas successfully serialized andfalsein case the node couldn't be serialized. - Throws:
org.w3c.dom.ls.LSException
-
-
writeToURI
public boolean writeToURI(org.w3c.dom.Node node, java.lang.String URI) throws org.w3c.dom.ls.LSExceptionDeprecated.Serialize the specified node as described above in the general description of theLSSerializerinterface. The output is written to the supplied URI.
When writing to a URI, the encoding is found by looking at the encoding information that is reachable through the item to be written (or its owner document) in this order:-
Document.inputEncoding, -
Document.xmlEncoding.
If no encoding is reachable through the above properties, a default encoding of "UTF-8" will be used.
If the specified encoding is not supported an "unsupported-encoding" error is raised.- Specified by:
writeToURIin interfaceorg.w3c.dom.ls.LSSerializer- Parameters:
node- The node to serialize.URI- The URI to write to.- Returns:
- Returns
trueifnodewas successfully serialized andfalsein case the node couldn't be serialized. - Throws:
org.w3c.dom.ls.LSException
-
-
-