APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.serializer.dom3

pack-priv final Class DOM3TreeWalker

extends Object
Class Inheritance
Imports
com.sun.org.apache.xerces.internal.util.XML11Char, .XMLChar, com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory, .SerializationHandler, com.sun.org.apache.xml.internal.serializer.utils.MsgKey, .Utils, java.io.IOException, .Writer, java.util.Collections, .Enumeration, .HashMap, .Map, .Properties, jdk.xml.internal.JdkXmlUtils, org.w3c.dom.Attr, .CDATASection, .Comment, .DOMError, .DOMErrorHandler, .Document, .DocumentType, .Element, .Entity, .EntityReference, .NamedNodeMap, .Node, .NodeList, .ProcessingInstruction, .Text, org.w3c.dom.ls.LSSerializerFilter, org.w3c.dom.traversal.NodeFilter, org.xml.sax.Locator, .SAXException, org.xml.sax.ext.LexicalHandler, org.xml.sax.helpers.LocatorImpl

Built on org.apache.xml.serializer.TreeWalker and adds functionality to traverse and serialize a DOM Node (Level 2 or Level 3) as specified in the DOM Level 3 LS Recommedation by evaluating and applying DOMConfiguration parameters and filters if any during serialization.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private Properties
fDOMConfigProperties

DOMConfiguration Properties

private int
fElementDepth

stores the current element depth

private DOMErrorHandler
fErrorHandler

ErrorHandler

private static final Map<String, Integer>
fFeatureMap

This table is a quick lookup of a property key (String) to the integer that is the bit to flip in the fFeatures field, so the integers should have values 1,2,4,8,16...

private int
fFeatures

DOM Configuration Parameters

private LSSerializerFilter
fFilter

LSSerializerFilter

private boolean
fInEntityRef

Keeps track if we are in an entity reference when entities=true

private boolean
fIsLevel3DOM

Is the Node a Level 3 DOM node

private boolean
fIsXMLVersion11

XML Version, default 1.0

private LexicalHandler
fLexicalHandler

If the serializer is an instance of a LexicalHandler

protected NamespaceSupport
fLocalNSBinder

stores all namespace bindings on the current element

private LocatorImpl
fLocator

Locator object for this TreeWalker

private String
fNewLine

New Line character to use in serialization

pack-priv boolean
fNextIsRaw

Flag indicating whether following text to be processed is raw text

protected NamespaceSupport
fNSBinder

stores namespaces in scope

private SerializationHandler
fSerializer

The SerializationHandler, it extends ContentHandler and when this class is instantiated via the constructor provided, a SerializationHandler object is passed to it.

private int
private String
fXMLVersion

Stores the version of the XML document to be serialize

private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final String
private static final String
private static final int
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
pack-priv
DOM3TreeWalker(SerializationHandler serialHandler, DOMErrorHandler errHandler, LSSerializerFilter filter, String newLine)

Constructor.

Method Summary

Modifier and TypeMethod and Description
protected boolean

Returns:

True if the node is to be serialized else false if the node is to be rejected or skipped.
applyFilter
(Node
The Node to serialize
node
,
int nodeType)

Applies a filter on the node to serialize

protected void
checkUnboundPrefixInEntRef(Node node)

If the configuration parameter "namespaces" is set to true, this methods checks if an entity whose replacement text contains unbound namespace prefixes is referenced in a location where there are no bindings for the namespace prefixes and if so raises a LSException with the error-type "unbound-prefix-in-entity-reference"

private final void
dispatachChars(Node node)

Optimized dispatch of characters.

protected void
endNode(Node
Node we just finished processing
node
)

End processing of given node

protected void
fixupElementNS(Node node)

Fixes an element's namespace

protected void
initProperties(Properties
DOMConfiguraiton properties that were set and which are to be used while serializing the DOM.
properties
)

Initializes fFeatures based on the DOMConfiguration Parameters set.

protected void

Returns:

a boolean indiacating if the comment is well-formed or not.
isAttributeWellFormed
(Node node)

Checks if an attr node is well-formed, by checking it's Name and value for well-formedness.

protected void
isCDATASectionWellFormed(CDATASection node)

Checks if an CDATASection node is well-formed, by checking it's data for well-formedness.

protected void

Returns:

a boolean indiacating if the comment is well-formed or not.
isCommentWellFormed
(String
The contents of the comment node
data
)

Checks if a comment node is well-formed

protected void

Returns:

a boolean indiacating if the comment is well-formed or not.
isElementWellFormed
(Node node)

Checks if an element node is well-formed, by checking its Name for well-formedness.

protected void
isEntityReferneceWellFormed(EntityReference node)

Checks if an EntityRefernece node is well-formed, by checking it's node name.

protected void
isPIWellFormed(ProcessingInstruction node)

Checks if a PI node is well-formed, by checking it's Name and data for well-formedness.

protected void
isTextWellFormed(Text node)

Checks if an Text node is well-formed, by checking if it contains invalid XML characters.

protected boolean
isValidQName(String
prefix of qualified name
prefix
,
String
local part of qualified name
local
,
boolean xml11Version)

Taken from org.apache.xerces.dom.CoreDocumentImpl Checks if the given qualified name is legal with respect to the version of XML to which this document must conform.

protected boolean
isWFXMLChar(String chardata, Character
A reference to the character to be returned that was determined invalid.
refInvalidChar
)

Checks if a XML character is well-formed

protected Character

Returns:

Character A reference to the character to be returned that was determined invalid.
isWFXMLChar
(String chardata)

Checks if a XML character is well-formed.

protected boolean
isXMLName(String s, boolean xml11Version)

Taken from org.apache.xerces.dom.CoreDocumentImpl Check the string against XML's definition of acceptable names for elements and attributes and so on using the XMLCharacterProperties utility class

protected void
recordLocalNSDecl(Node node)

Records local namespace declarations, to be used for normalization later

protected void
serializeAttList(Element
The OwnerElement whose Attr Nodes are to be serialized.
node
)

Serializes the Attr Nodes of an Element.

protected void
serializeCDATASection(CDATASection
The CDATASection Node to serialize
node
)

Serializes an CDATASection Node.

protected void
serializeComment(Comment
The Comment Node to serialize
node
)

Serializes a Comment Node.

protected void
serializeDocType(DocumentType
The Docuemnt Type Node to serialize
node
,
boolean
Invoked at the start or end of node. Default true.
bStart
)

Serializes a Document Type Node.

protected void
serializeElement(Element
The Element Node to serialize
node
,
boolean
Invoked at the start or end of node.
bStart
)

Serializes an Element Node.

protected void
serializeEntityReference(EntityReference
The EntityReference Node to serialize
node
,
boolean
Inicates if called from start or endNode
bStart
)

Serializes an EntityReference Node.

protected void
serializePI(ProcessingInstruction
The ProcessingInstruction Node to serialize
node
)

Serializes an ProcessingInstruction Node.

protected void
serializeText(Text
The Text Node to serialize
node
)

Serializes an Text Node.

protected void
startNode(Node
Node to process
node
)

Start processing given node

public void
traverse(Node
Node in the tree where to start traversal
pos
)

Perform a pre-order traversal non-recursive style.

public void
traverse(Node
Node in the tree where to start traversal
pos
,
Node
Node in the tree where to end traversal
top
)

Perform a pre-order traversal non-recursive style.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CANONICALback to summary
private static final int CANONICAL
CDATAback to summary
private static final int CDATA
CHARNORMALIZEback to summary
private static final int CHARNORMALIZE
COMMENTSback to summary
private static final int COMMENTS
DISCARDDEFAULTback to summary
private static final int DISCARDDEFAULT
DTNORMALIZEback to summary
private static final int DTNORMALIZE
ELEM_CONTENT_WHITESPACEback to summary
private static final int ELEM_CONTENT_WHITESPACE
ENTITIESback to summary
private static final int ENTITIES
fDOMConfigPropertiesback to summary
private Properties fDOMConfigProperties

DOMConfiguration Properties

fElementDepthback to summary
private int fElementDepth

stores the current element depth

fErrorHandlerback to summary
private DOMErrorHandler fErrorHandler

ErrorHandler

fFeatureMapback to summary
private static final Map<String, Integer> fFeatureMap

This table is a quick lookup of a property key (String) to the integer that is the bit to flip in the fFeatures field, so the integers should have values 1,2,4,8,16...

fFeaturesback to summary
private int fFeatures

DOM Configuration Parameters

fFilterback to summary
private LSSerializerFilter fFilter

LSSerializerFilter

fInEntityRefback to summary
private boolean fInEntityRef

Keeps track if we are in an entity reference when entities=true

fIsLevel3DOMback to summary
private boolean fIsLevel3DOM

Is the Node a Level 3 DOM node

fIsXMLVersion11back to summary
private boolean fIsXMLVersion11

XML Version, default 1.0

fLexicalHandlerback to summary
private LexicalHandler fLexicalHandler

If the serializer is an instance of a LexicalHandler

fLocalNSBinderback to summary
protected NamespaceSupport fLocalNSBinder

stores all namespace bindings on the current element

fLocatorback to summary
private LocatorImpl fLocator

Locator object for this TreeWalker

fNewLineback to summary
private String fNewLine

New Line character to use in serialization

fNextIsRawback to summary
pack-priv boolean fNextIsRaw

Flag indicating whether following text to be processed is raw text

fNSBinderback to summary
protected NamespaceSupport fNSBinder

stores namespaces in scope

fSerializerback to summary
private SerializationHandler fSerializer

The SerializationHandler, it extends ContentHandler and when this class is instantiated via the constructor provided, a SerializationHandler object is passed to it.

fWhatToShowFilterback to summary
private int fWhatToShowFilter
fXMLVersionback to summary
private String fXMLVersion

Stores the version of the XML document to be serialize

IGNORE_CHAR_DENORMALIZEback to summary
private static final int IGNORE_CHAR_DENORMALIZE
INFOSETback to summary
private static final int INFOSET
NAMESPACEDECLSback to summary
private static final int NAMESPACEDECLS
NAMESPACESback to summary
private static final int NAMESPACES
NORMALIZECHARSback to summary
private static final int NORMALIZECHARS
PRETTY_PRINTback to summary
private static final int PRETTY_PRINT
SCHEMAVALIDATEback to summary
private static final int SCHEMAVALIDATE
SPLITCDATAback to summary
private static final int SPLITCDATA
VALIDATEback to summary
private static final int VALIDATE
WELLFORMEDback to summary
private static final int WELLFORMED
XML_PREFIXback to summary
private static final String XML_PREFIX
XML_URIback to summary
private static final String XML_URI
XMLDECLback to summary
private static final int XMLDECL
XMLNS_PREFIXback to summary
private static final String XMLNS_PREFIX
XMLNS_URIback to summary
private static final String XMLNS_URI

Constructor Detail

DOM3TreeWalkerback to summary
pack-priv DOM3TreeWalker(SerializationHandler serialHandler, DOMErrorHandler errHandler, LSSerializerFilter filter, String newLine)

Constructor.

Method Detail

applyFilterback to summary
protected boolean applyFilter(Node node, int nodeType)

Applies a filter on the node to serialize

Parameters
node:Node

The Node to serialize

Returns:boolean

True if the node is to be serialized else false if the node is to be rejected or skipped.

checkUnboundPrefixInEntRefback to summary
protected void checkUnboundPrefixInEntRef(Node node)

If the configuration parameter "namespaces" is set to true, this methods checks if an entity whose replacement text contains unbound namespace prefixes is referenced in a location where there are no bindings for the namespace prefixes and if so raises a LSException with the error-type "unbound-prefix-in-entity-reference"

dispatachCharsback to summary
private final void dispatachChars(Node node) throws SAXException

Optimized dispatch of characters.

endNodeback to summary
protected void endNode(Node node) throws SAXException

End processing of given node

Parameters
node:Node

Node we just finished processing

fixupElementNSback to summary
protected void fixupElementNS(Node node) throws SAXException

Fixes an element's namespace

initPropertiesback to summary
protected void initProperties(Properties properties)

Initializes fFeatures based on the DOMConfiguration Parameters set.

Parameters
properties:Properties

DOMConfiguraiton properties that were set and which are to be used while serializing the DOM.

isAttributeWellFormedback to summary
protected void isAttributeWellFormed(Node node)

Checks if an attr node is well-formed, by checking it's Name and value for well-formedness.

Returns:void

a boolean indiacating if the comment is well-formed or not.

isCDATASectionWellFormedback to summary
protected void isCDATASectionWellFormed(CDATASection node)

Checks if an CDATASection node is well-formed, by checking it's data for well-formedness. Note that the presence of a CDATA termination mark in the contents of a CDATASection is handled by the parameter spli-cdata-sections

isCommentWellFormedback to summary
protected void isCommentWellFormed(String data)

Checks if a comment node is well-formed

Parameters
data:String

The contents of the comment node

Returns:void

a boolean indiacating if the comment is well-formed or not.

isElementWellFormedback to summary
protected void isElementWellFormed(Node node)

Checks if an element node is well-formed, by checking its Name for well-formedness.

Returns:void

a boolean indiacating if the comment is well-formed or not.

isEntityReferneceWellFormedback to summary
protected void isEntityReferneceWellFormed(EntityReference node)

Checks if an EntityRefernece node is well-formed, by checking it's node name. Then depending on whether it is referenced in Element content or in an Attr Node, checks if the EntityReference references an unparsed entity or a external entity and if so throws raises the appropriate well-formedness error.

isPIWellFormedback to summary
protected void isPIWellFormed(ProcessingInstruction node)

Checks if a PI node is well-formed, by checking it's Name and data for well-formedness.

isTextWellFormedback to summary
protected void isTextWellFormed(Text node)

Checks if an Text node is well-formed, by checking if it contains invalid XML characters.

isValidQNameback to summary
protected boolean isValidQName(String prefix, String local, boolean xml11Version)

Taken from org.apache.xerces.dom.CoreDocumentImpl Checks if the given qualified name is legal with respect to the version of XML to which this document must conform.

Parameters
prefix:String

prefix of qualified name

local:String

local part of qualified name

isWFXMLCharback to summary
protected boolean isWFXMLChar(String chardata, Character refInvalidChar)

Checks if a XML character is well-formed

Parameters
refInvalidChar:Character

A reference to the character to be returned that was determined invalid.

isWFXMLCharback to summary
protected Character isWFXMLChar(String chardata)

Checks if a XML character is well-formed. If there is a problem with the character a non-null Character is returned else null is returned.

Returns:Character

Character A reference to the character to be returned that was determined invalid.

isXMLNameback to summary
protected boolean isXMLName(String s, boolean xml11Version)

Taken from org.apache.xerces.dom.CoreDocumentImpl Check the string against XML's definition of acceptable names for elements and attributes and so on using the XMLCharacterProperties utility class

recordLocalNSDeclback to summary
protected void recordLocalNSDecl(Node node)

Records local namespace declarations, to be used for normalization later

serializeAttListback to summary
protected void serializeAttList(Element node) throws SAXException

Serializes the Attr Nodes of an Element.

Parameters
node:Element

The OwnerElement whose Attr Nodes are to be serialized.

serializeCDATASectionback to summary
protected void serializeCDATASection(CDATASection node) throws SAXException

Serializes an CDATASection Node.

Parameters
node:CDATASection

The CDATASection Node to serialize

serializeCommentback to summary
protected void serializeComment(Comment node) throws SAXException

Serializes a Comment Node.

Parameters
node:Comment

The Comment Node to serialize

serializeDocTypeback to summary
protected void serializeDocType(DocumentType node, boolean bStart) throws SAXException

Serializes a Document Type Node.

Parameters
node:DocumentType

The Docuemnt Type Node to serialize

bStart:boolean

Invoked at the start or end of node. Default true.

serializeElementback to summary
protected void serializeElement(Element node, boolean bStart) throws SAXException

Serializes an Element Node.

Parameters
node:Element

The Element Node to serialize

bStart:boolean

Invoked at the start or end of node.

serializeEntityReferenceback to summary
protected void serializeEntityReference(EntityReference node, boolean bStart) throws SAXException

Serializes an EntityReference Node.

Parameters
node:EntityReference

The EntityReference Node to serialize

bStart:boolean

Inicates if called from start or endNode

serializePIback to summary
protected void serializePI(ProcessingInstruction node) throws SAXException

Serializes an ProcessingInstruction Node.

Parameters
node:ProcessingInstruction

The ProcessingInstruction Node to serialize

serializeTextback to summary
protected void serializeText(Text node) throws SAXException

Serializes an Text Node.

Parameters
node:Text

The Text Node to serialize

startNodeback to summary
protected void startNode(Node node) throws SAXException

Start processing given node

Parameters
node:Node

Node to process

traverseback to summary
public void traverse(Node pos) throws SAXException

Perform a pre-order traversal non-recursive style. Note that TreeWalker assumes that the subtree is intended to represent a complete (though not necessarily well-formed) document and, during a traversal, startDocument and endDocument will always be issued to the SAX listener.

Parameters
pos:Node

Node in the tree where to start traversal

traverseback to summary
public void traverse(Node pos, Node top) throws SAXException

Perform a pre-order traversal non-recursive style. Note that TreeWalker assumes that the subtree is intended to represent a complete (though not necessarily well-formed) document and, during a traversal, startDocument and endDocument will always be issued to the SAX listener.

Parameters
pos:Node

Node in the tree where to start traversal

top:Node

Node in the tree where to end traversal