Package org.apache.ws.commons.serialize
Class DOMSerializer
- java.lang.Object
-
- org.apache.ws.commons.serialize.DOMSerializer
-
public class DOMSerializer extends java.lang.ObjectSerializes a DOM node into a stream of SAX events.
-
-
Field Summary
Fields Modifier and Type Field Description private booleannamespaceDeclarationAttributeprivate booleanparentsNamespaceDeclarationDisabledprivate booleanstartingDocument
-
Constructor Summary
Constructors Constructor Description DOMSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcharacters(org.xml.sax.ContentHandler pHandler, java.lang.String pValue, boolean pCdata)protected voiddoSerialize(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler)Converts the given nodepNodeinto a stream of SAX events, which are fired into the content handlerpHandler.protected voiddoSerializeChilds(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler)Serializes the childs ofpNode.private voidendPrefixMappingEvents(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler)Creates endPrefixMapping events for the nodepNode.booleanisNamespaceDeclarationAttribute()Returns whether XML declarations are being serialized as attributes or as SAX events (default).booleanisParentsNamespaceDeclarationDisabled()Sets whether XML declarations present in the parent nodes are being serialized (default) or not.booleanisStartingDocument()Returns, whetherstartDocumentandendDocumentevents are generated for document nodes.private voidparentsEndPrefixMappingEvents(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler)Finally creates endPrefixMapping events for the nodes parents.private voidparentsStartPrefixMappingEvents(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler)Initially creates startPrefixMapping events for the nodes parents.voidserialize(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler)Converts the given nodepNodeinto a stream of SAX events, which are fired into the content handlerpHandler.voidsetNamespaceDeclarationAttribute(boolean pXmlDeclarationAttribute)Sets whether XML namespace declarations are being serialized as attributes or as SAX events (default).voidsetParentsNamespaceDeclarationDisabled(boolean pParentsXmlDeclarationDisabled)Returns whether XML declarations present in the parent nodes are being serialized (default) or not.voidsetStartingDocument(boolean pStartingDocument)Sets, whetherstartDocumentandendDocumentevents are generated for document nodes.private voidstartPrefixMappingEvents(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler)Creates startPrefixMapping events for the nodepNode.
-
-
-
Method Detail
-
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 thenamespaceDeclarationAttributeproperts 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 thenamespaceDeclarationAttributeproperts is false.- Returns:
- True, if namespace declarations of the parent nodes are disabled, false otherwise.
-
isStartingDocument
public boolean isStartingDocument()
Returns, whetherstartDocumentandendDocumentevents are generated for document nodes.- Returns:
- True (default), if
startDocumentandendDocumentevents are being generated. False otherwise.
-
setStartingDocument
public void setStartingDocument(boolean pStartingDocument)
Sets, whetherstartDocumentandendDocumentevents are generated for document nodes.- Parameters:
pStartingDocument- True (default), ifstartDocumentandendDocumentevents are being generated. False otherwise.
-
doSerializeChilds
protected void doSerializeChilds(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler) throws org.xml.sax.SAXExceptionSerializes the childs ofpNode.- Parameters:
pNode- The parent node, whose childs are being serialized.pHandler- The target handler.- Throws:
org.xml.sax.SAXException- The target handler reported an error.
-
parentsStartPrefixMappingEvents
private void parentsStartPrefixMappingEvents(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler) throws org.xml.sax.SAXExceptionInitially 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:
org.xml.sax.SAXException- The target handler reported an error.
-
parentsEndPrefixMappingEvents
private void parentsEndPrefixMappingEvents(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler) throws org.xml.sax.SAXExceptionFinally 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:
org.xml.sax.SAXException- The target handler reported an error.
-
startPrefixMappingEvents
private void startPrefixMappingEvents(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler) throws org.xml.sax.SAXExceptionCreates startPrefixMapping events for the nodepNode.- Parameters:
pNode- The node being serialized.pHandler- The target handler.- Throws:
org.xml.sax.SAXException- The target handler reported an error.
-
endPrefixMappingEvents
private void endPrefixMappingEvents(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler) throws org.xml.sax.SAXExceptionCreates endPrefixMapping events for the nodepNode.- Parameters:
pNode- The node being serialized.pHandler- The target handler.- Throws:
org.xml.sax.SAXException- The target handler reported an error.
-
characters
private void characters(org.xml.sax.ContentHandler pHandler, java.lang.String pValue, boolean pCdata) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
serialize
public void serialize(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler) throws org.xml.sax.SAXExceptionConverts the given nodepNodeinto a stream of SAX events, which are fired into the content handlerpHandler.- Parameters:
pNode- The node being serialized.pHandler- The target handler.- Throws:
org.xml.sax.SAXException- The target handler reported an error.
-
doSerialize
protected void doSerialize(org.w3c.dom.Node pNode, org.xml.sax.ContentHandler pHandler) throws org.xml.sax.SAXExceptionConverts the given nodepNodeinto 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:
org.xml.sax.SAXException- The target handler reported an error.
-
-