|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xml.serializer.dom3.DOM3TreeWalker
final class DOM3TreeWalker
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 | |
---|---|
private static int |
CANONICAL
|
private static int |
CDATA
|
private static int |
CHARNORMALIZE
|
private static int |
COMMENTS
|
private static int |
DISCARDDEFAULT
|
private static int |
DTNORMALIZE
|
private static int |
ELEM_CONTENT_WHITESPACE
|
private static int |
ENTITIES
|
private java.util.Properties |
fDOMConfigProperties
DOMConfiguration Properties |
private int |
fElementDepth
stores the current element depth |
private org.w3c.dom.DOMErrorHandler |
fErrorHandler
ErrorHandler |
private int |
fFeatures
DOM Configuration Parameters |
private org.w3c.dom.ls.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 org.xml.sax.ext.LexicalHandler |
fLexicalHandler
If the serializer is an instance of a LexicalHandler |
protected NamespaceSupport |
fLocalNSBinder
stores all namespace bindings on the current element |
private org.xml.sax.helpers.LocatorImpl |
fLocator
Locator object for this TreeWalker |
private java.lang.String |
fNewLine
New Line character to use in serialization |
(package private) 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 |
fWhatToShowFilter
|
private java.lang.String |
fXMLVersion
Stores the version of the XML document to be serialize |
private static int |
IGNORE_CHAR_DENORMALIZE
|
private static int |
INFOSET
|
private static int |
NAMESPACEDECLS
|
private static int |
NAMESPACES
|
private static int |
NORMALIZECHARS
|
private static int |
PRETTY_PRINT
|
private static java.util.Hashtable |
s_propKeys
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 static int |
SCHEMAVALIDATE
|
private static int |
SPLITCDATA
|
private static int |
VALIDATE
|
private static int |
WELLFORMED
|
private static java.lang.String |
XML_PREFIX
|
private static java.lang.String |
XML_URI
|
private static int |
XMLDECL
|
private static java.lang.String |
XMLNS_PREFIX
|
private static java.lang.String |
XMLNS_URI
|
Constructor Summary | |
---|---|
DOM3TreeWalker(SerializationHandler serialHandler,
org.w3c.dom.DOMErrorHandler errHandler,
org.w3c.dom.ls.LSSerializerFilter filter,
java.lang.String newLine)
Constructor. |
Method Summary | |
---|---|
protected boolean |
applyFilter(org.w3c.dom.Node node,
int nodeType)
Applies a filter on the node to serialize |
protected void |
checkUnboundPrefixInEntRef(org.w3c.dom.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 void |
dispatachChars(org.w3c.dom.Node node)
Optimized dispatch of characters. |
protected void |
endNode(org.w3c.dom.Node node)
End processing of given node |
protected void |
fixupElementNS(org.w3c.dom.Node node)
Fixes an element's namespace |
protected void |
initProperties(java.util.Properties properties)
Initializes fFeatures based on the DOMConfiguration Parameters set. |
protected void |
isAttributeWellFormed(org.w3c.dom.Node node)
Checks if an attr node is well-formed, by checking it's Name and value for well-formedness. |
protected void |
isCDATASectionWellFormed(org.w3c.dom.CDATASection node)
Checks if an CDATASection node is well-formed, by checking it's data for well-formedness. |
protected void |
isCommentWellFormed(java.lang.String data)
Checks if a comment node is well-formed |
protected void |
isElementWellFormed(org.w3c.dom.Node node)
Checks if an element node is well-formed, by checking its Name for well-formedness. |
protected void |
isEntityReferneceWellFormed(org.w3c.dom.EntityReference node)
Checks if an EntityRefernece node is well-formed, by checking it's node name. |
protected void |
isPIWellFormed(org.w3c.dom.ProcessingInstruction node)
Checks if a PI node is well-formed, by checking it's Name and data for well-formedness. |
protected void |
isTextWellFormed(org.w3c.dom.Text node)
Checks if an Text node is well-formed, by checking if it contains invalid XML characters. |
protected boolean |
isValidQName(java.lang.String prefix,
java.lang.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. |
protected java.lang.Character |
isWFXMLChar(java.lang.String chardata)
Checks if a XML character is well-formed. |
protected boolean |
isWFXMLChar(java.lang.String chardata,
java.lang.Character refInvalidChar)
Checks if a XML character is well-formed |
protected boolean |
isXMLName(java.lang.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(org.w3c.dom.Node node)
Records local namespace declarations, to be used for normalization later |
protected void |
serializeAttList(org.w3c.dom.Element node)
Serializes the Attr Nodes of an Element. |
protected void |
serializeCDATASection(org.w3c.dom.CDATASection node)
Serializes an CDATASection Node. |
protected void |
serializeComment(org.w3c.dom.Comment node)
Serializes a Comment Node. |
protected void |
serializeDocType(org.w3c.dom.DocumentType node,
boolean bStart)
Serializes a Document Type Node. |
protected void |
serializeElement(org.w3c.dom.Element node,
boolean bStart)
Serializes an Element Node. |
protected void |
serializeEntityReference(org.w3c.dom.EntityReference node,
boolean bStart)
Serializes an EntityReference Node. |
protected void |
serializePI(org.w3c.dom.ProcessingInstruction node)
Serializes an ProcessingInstruction Node. |
protected void |
serializeText(org.w3c.dom.Text node)
Serializes an Text Node. |
protected void |
startNode(org.w3c.dom.Node node)
Start processing given node |
void |
traverse(org.w3c.dom.Node pos)
Perform a pre-order traversal non-recursive style. |
void |
traverse(org.w3c.dom.Node pos,
org.w3c.dom.Node top)
Perform a pre-order traversal non-recursive style. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private SerializationHandler fSerializer
private org.xml.sax.helpers.LocatorImpl fLocator
private org.w3c.dom.DOMErrorHandler fErrorHandler
private org.w3c.dom.ls.LSSerializerFilter fFilter
private org.xml.sax.ext.LexicalHandler fLexicalHandler
private int fWhatToShowFilter
private java.lang.String fNewLine
private java.util.Properties fDOMConfigProperties
private boolean fInEntityRef
private java.lang.String fXMLVersion
private boolean fIsXMLVersion11
private boolean fIsLevel3DOM
private int fFeatures
boolean fNextIsRaw
private static final java.lang.String XMLNS_URI
private static final java.lang.String XMLNS_PREFIX
private static final java.lang.String XML_URI
private static final java.lang.String XML_PREFIX
protected NamespaceSupport fNSBinder
protected NamespaceSupport fLocalNSBinder
private int fElementDepth
private static final int CANONICAL
private static final int CDATA
private static final int CHARNORMALIZE
private static final int COMMENTS
private static final int DTNORMALIZE
private static final int ELEM_CONTENT_WHITESPACE
private static final int ENTITIES
private static final int INFOSET
private static final int NAMESPACES
private static final int NAMESPACEDECLS
private static final int NORMALIZECHARS
private static final int SPLITCDATA
private static final int VALIDATE
private static final int SCHEMAVALIDATE
private static final int WELLFORMED
private static final int DISCARDDEFAULT
private static final int PRETTY_PRINT
private static final int IGNORE_CHAR_DENORMALIZE
private static final int XMLDECL
private static final java.util.Hashtable s_propKeys
Constructor Detail |
---|
DOM3TreeWalker(SerializationHandler serialHandler, org.w3c.dom.DOMErrorHandler errHandler, org.w3c.dom.ls.LSSerializerFilter filter, java.lang.String newLine)
contentHandler
- serialHandler The implemention of the SerializationHandler interfaceMethod Detail |
---|
public void traverse(org.w3c.dom.Node pos) throws org.xml.sax.SAXException
pos
- Node in the tree where to start traversal
TransformerException
org.xml.sax.SAXException
public void traverse(org.w3c.dom.Node pos, org.w3c.dom.Node top) throws org.xml.sax.SAXException
pos
- Node in the tree where to start traversaltop
- Node in the tree where to end traversal
TransformerException
org.xml.sax.SAXException
private final void dispatachChars(org.w3c.dom.Node node) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void startNode(org.w3c.dom.Node node) throws org.xml.sax.SAXException
node
- Node to process
org.xml.sax.SAXException
protected void endNode(org.w3c.dom.Node node) throws org.xml.sax.SAXException
node
- Node we just finished processing
org.xml.sax.SAXException
protected boolean applyFilter(org.w3c.dom.Node node, int nodeType)
node
- The Node to serialize
protected void serializeDocType(org.w3c.dom.DocumentType node, boolean bStart) throws org.xml.sax.SAXException
node
- The Docuemnt Type Node to serializebStart
- Invoked at the start or end of node. Default true.
org.xml.sax.SAXException
protected void serializeComment(org.w3c.dom.Comment node) throws org.xml.sax.SAXException
node
- The Comment Node to serialize
org.xml.sax.SAXException
protected void serializeElement(org.w3c.dom.Element node, boolean bStart) throws org.xml.sax.SAXException
node
- The Element Node to serializebStart
- Invoked at the start or end of node.
org.xml.sax.SAXException
protected void serializeAttList(org.w3c.dom.Element node) throws org.xml.sax.SAXException
node
- The OwnerElement whose Attr Nodes are to be serialized.
org.xml.sax.SAXException
protected void serializePI(org.w3c.dom.ProcessingInstruction node) throws org.xml.sax.SAXException
node
- The ProcessingInstruction Node to serialize
org.xml.sax.SAXException
protected void serializeCDATASection(org.w3c.dom.CDATASection node) throws org.xml.sax.SAXException
node
- The CDATASection Node to serialize
org.xml.sax.SAXException
protected void serializeText(org.w3c.dom.Text node) throws org.xml.sax.SAXException
node
- The Text Node to serialize
org.xml.sax.SAXException
protected void serializeEntityReference(org.w3c.dom.EntityReference node, boolean bStart) throws org.xml.sax.SAXException
node
- The EntityReference Node to serializebStart
- Inicates if called from start or endNode
org.xml.sax.SAXException
protected boolean isXMLName(java.lang.String s, boolean xml11Version)
protected boolean isValidQName(java.lang.String prefix, java.lang.String local, boolean xml11Version)
prefix
- prefix of qualified namelocal
- local part of qualified nameprotected boolean isWFXMLChar(java.lang.String chardata, java.lang.Character refInvalidChar)
characters
- A String of characters to be checked for Well-FormednessrefInvalidChar
- A reference to the character to be returned that was determined invalid.protected java.lang.Character isWFXMLChar(java.lang.String chardata)
characters
- A String of characters to be checked for Well-Formedness
protected void isCommentWellFormed(java.lang.String data)
data
- The contents of the comment nodeprotected void isElementWellFormed(org.w3c.dom.Node node)
data
- The contents of the comment nodeprotected void isAttributeWellFormed(org.w3c.dom.Node node)
data
- The contents of the comment nodeprotected void isPIWellFormed(org.w3c.dom.ProcessingInstruction node)
data
- The contents of the comment nodeprotected void isCDATASectionWellFormed(org.w3c.dom.CDATASection node)
data
- The contents of the comment nodeprotected void isTextWellFormed(org.w3c.dom.Text node)
data
- The contents of the comment nodeprotected void isEntityReferneceWellFormed(org.w3c.dom.EntityReference node)
data
- The contents of the comment nodeprotected void checkUnboundPrefixInEntRef(org.w3c.dom.Node node)
Node,
- The EntityReference nodes whose children are to be checkedprotected void recordLocalNSDecl(org.w3c.dom.Node node)
Node,
- The element node, whose namespace declarations are to be recordedprotected void fixupElementNS(org.w3c.dom.Node node) throws org.xml.sax.SAXException
Node,
- The element node, whose namespace is to be fixed
org.xml.sax.SAXException
protected void initProperties(java.util.Properties properties)
properties
- DOMConfiguraiton properties that were set and which are
to be used while serializing the DOM.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |