Package org.apache.ws.commons.serialize
Class DOMSerializer
java.lang.Object
org.apache.ws.commons.serialize.DOMSerializer
Serializes a DOM node into a stream of SAX events.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
characters
(ContentHandler pHandler, String pValue, boolean pCdata) protected void
doSerialize
(Node pNode, ContentHandler pHandler) Converts the given nodepNode
into a stream of SAX events, which are fired into the content handlerpHandler
.protected void
doSerializeChilds
(Node pNode, ContentHandler pHandler) Serializes the childs ofpNode
.private void
endPrefixMappingEvents
(Node pNode, ContentHandler pHandler) Creates endPrefixMapping events for the nodepNode
.boolean
Returns whether XML declarations are being serialized as attributes or as SAX events (default).boolean
Sets whether XML declarations present in the parent nodes are being serialized (default) or not.boolean
Returns, whetherstartDocument
andendDocument
events are generated for document nodes.private void
parentsEndPrefixMappingEvents
(Node pNode, ContentHandler pHandler) Finally creates endPrefixMapping events for the nodes parents.private void
parentsStartPrefixMappingEvents
(Node pNode, ContentHandler pHandler) Initially creates startPrefixMapping events for the nodes parents.void
serialize
(Node pNode, ContentHandler pHandler) Converts the given nodepNode
into a stream of SAX events, which are fired into the content handlerpHandler
.void
setNamespaceDeclarationAttribute
(boolean pXmlDeclarationAttribute) Sets whether XML namespace declarations are being serialized as attributes or as SAX events (default).void
setParentsNamespaceDeclarationDisabled
(boolean pParentsXmlDeclarationDisabled) Returns whether XML declarations present in the parent nodes are being serialized (default) or not.void
setStartingDocument
(boolean pStartingDocument) Sets, whetherstartDocument
andendDocument
events are generated for document nodes.private void
startPrefixMappingEvents
(Node pNode, ContentHandler pHandler) Creates startPrefixMapping events for the nodepNode
.
-
Field Details
-
namespaceDeclarationAttribute
private boolean namespaceDeclarationAttribute -
parentsNamespaceDeclarationDisabled
private boolean parentsNamespaceDeclarationDisabled -
startingDocument
private boolean startingDocument
-
-
Constructor Details
-
DOMSerializer
public DOMSerializer()
-
-
Method Details
-
setNamespaceDeclarationAttribute
public void setNamespaceDeclarationAttribute(boolean pXmlDeclarationAttribute) Sets whether XML namespace declarations are being serialized as attributes or as SAX events (default).- Parameters:
pXmlDeclarationAttribute
- True, if a namespace declaration is being transmitted as an XML attribute. False otherwise.
-
isNamespaceDeclarationAttribute
public boolean isNamespaceDeclarationAttribute()Returns whether XML declarations are being serialized as attributes or as SAX events (default).- Returns:
- True, if a namespace declaration is being transmitted as an XML attribute. False otherwise.
-
setParentsNamespaceDeclarationDisabled
public void setParentsNamespaceDeclarationDisabled(boolean pParentsXmlDeclarationDisabled) Returns whether XML declarations present in the parent nodes are being serialized (default) or not. This option takes effect only if the namespace declarations are sent as events. In other words, if thenamespaceDeclarationAttribute
properts is false.- Parameters:
pParentsXmlDeclarationDisabled
- True, if namespace declarations of the parent nodes are disabled, false otherwise.
-
isParentsNamespaceDeclarationDisabled
public boolean isParentsNamespaceDeclarationDisabled()Sets whether XML declarations present in the parent nodes are being serialized (default) or not. This option takes effect only if the namespace declarations are sent as events. In other words, if thenamespaceDeclarationAttribute
properts is false.- Returns:
- True, if namespace declarations of the parent nodes are disabled, false otherwise.
-
isStartingDocument
public boolean isStartingDocument()Returns, whetherstartDocument
andendDocument
events are generated for document nodes.- Returns:
- True (default), if
startDocument
andendDocument
events are being generated. False otherwise.
-
setStartingDocument
public void setStartingDocument(boolean pStartingDocument) Sets, whetherstartDocument
andendDocument
events are generated for document nodes.- Parameters:
pStartingDocument
- True (default), ifstartDocument
andendDocument
events are being generated. False otherwise.
-
doSerializeChilds
Serializes the childs ofpNode
.- Parameters:
pNode
- The parent node, whose childs are being serialized.pHandler
- The target handler.- Throws:
SAXException
- The target handler reported an error.
-
parentsStartPrefixMappingEvents
private void parentsStartPrefixMappingEvents(Node pNode, ContentHandler pHandler) throws SAXException Initially creates startPrefixMapping events for the nodes parents. This is invoked only, ifisNamespaceDeclarationAttribute()
, andisParentsNamespaceDeclarationDisabled()
are false.- Parameters:
pNode
- The node, for which namespace declarations are being created.pHandler
- The target handler.- Throws:
SAXException
- The target handler reported an error.
-
parentsEndPrefixMappingEvents
Finally creates endPrefixMapping events for the nodes parents. This is invoked only, ifisNamespaceDeclarationAttribute()
, andisParentsNamespaceDeclarationDisabled()
are false.- Parameters:
pNode
- The node, for which namespace declarations are being created.pHandler
- The target handler.- Throws:
SAXException
- The target handler reported an error.
-
startPrefixMappingEvents
Creates startPrefixMapping events for the nodepNode
.- Parameters:
pNode
- The node being serialized.pHandler
- The target handler.- Throws:
SAXException
- The target handler reported an error.
-
endPrefixMappingEvents
Creates endPrefixMapping events for the nodepNode
.- Parameters:
pNode
- The node being serialized.pHandler
- The target handler.- Throws:
SAXException
- The target handler reported an error.
-
characters
- Throws:
SAXException
-
serialize
Converts the given nodepNode
into a stream of SAX events, which are fired into the content handlerpHandler
.- Parameters:
pNode
- The node being serialized.pHandler
- The target handler.- Throws:
SAXException
- The target handler reported an error.
-
doSerialize
Converts the given nodepNode
into a stream of SAX events, which are fired into the content handlerpHandler
. Unlikeserialize(Node, ContentHandler)
, this method doesn't callparentsStartPrefixMappingEvents(Node, ContentHandler)
, andparentsEndPrefixMappingEvents(Node, ContentHandler)
.- Parameters:
pNode
- The node being serialized.pHandler
- The target handler.- Throws:
SAXException
- The target handler reported an error.
-