APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.org.apache.xerces.internal.dom

public Class DOMNormalizer

extends Object
implements XMLDocumentHandler
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler
Imports
com.sun.org.apache.xerces.internal.impl.Constants, .RevalidationHandler, com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDLoader, .XMLDTDValidator, com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType, com.sun.org.apache.xerces.internal.impl.xs.util.SimpleLocator, com.sun.org.apache.xerces.internal.util.AugmentationsImpl, .NamespaceSupport, .SymbolTable, .XML11Char, .XMLChar, .XMLSymbols, com.sun.org.apache.xerces.internal.xni.Augmentations, .NamespaceContext, .QName, .XMLAttributes, .XMLDocumentHandler, .XMLLocator, .XMLResourceIdentifier, .XMLString, .XNIException, com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription, com.sun.org.apache.xerces.internal.xni.parser.XMLComponent, .XMLDocumentSource, com.sun.org.apache.xerces.internal.xs.AttributePSVI, .ElementPSVI, .XSTypeDefinition, java.io.IOException, java.util.ArrayList, .List, .Vector, org.w3c.dom.Attr, .Comment, .DOMError, .DOMErrorHandler, .Document, .DocumentType, .Element, .Entity, .NamedNodeMap, .Node, .NodeList, .ProcessingInstruction, .Text

This class adds implementation for normalizeDocument method. It acts as if the document was going through a save and load cycle, putting the document in a "normal" form. The actual result depends on the features being set and governing what operations actually take place. See setNormalizationFeature for details. Noticeably this method normalizes Text nodes, makes the document "namespace wellformed", according to the algorithm described below in pseudo code, by adding missing namespace declaration attributes and adding or changing namespace prefixes, updates the replacement tree of EntityReference nodes, normalizes attribute values, etc. Mutation events, when supported, are generated to reflect the changes occuring on the document. See Namespace normalization for details on how namespace declaration attributes and prefixes are normalized.

Note

There is an initial support for DOM revalidation with XML Schema as a grammar. The tree might not be validated correctly if entityReferences, CDATA sections are present in the tree. The PSVI information is not exposed, normalized data (including element default content is not available).

Authors
Elena Litani, IBM, Neeraj Bajaj, Sun Microsystems, inc.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class

Field Summary

Modifier and TypeField and Description
protected static final boolean
DEBUG

Debug namespace fix up algorithm

protected static final boolean
DEBUG_EVENTS

Debug document handler events

protected static final boolean
DEBUG_ND

Debug normalize document

public static final XMLString
EMPTY_STRING

Empty string to pass to the validator.

private boolean
protected final DOMNormalizer.XMLAttributesProxy
private final QName
protected DOMConfigurationImpl
protected Node
fCurrentNode

for setting the PSVI

protected CoreDocumentImpl
private XMLDTDValidator
private final DOMErrorImpl
fError

Cached DOMError impl.

protected DOMErrorHandler
fErrorHandler

error handler.

protected final NamespaceContext
fLocalNSBinder

Stores all namespace bindings on the current element

protected final DOMLocatorImpl
fLocator

DOM Locator - for namespace fixup algorithm

protected final NamespaceContext
fNamespaceContext

The namespace context of this document: stores namespaces in scope

protected boolean
pack-priv final XMLString
protected boolean
protected final QName
protected SymbolTable
fSymbolTable

symbol table

protected RevalidationHandler
fValidationHandler

Validation handler represents validator instance.

protected static final String
PREFIX

prefix added by namespace fixup algorithm should follow a pattern "NS" + index

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected final void
addNamespaceDecl(String prefix, String uri, ElementImpl element)

Adds a namespace attribute or replaces the value of existing namespace attribute with the given prefix and value for URI.

public void
characters(XMLString
The content.
text
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.characters.

Character content.

public void
comment(XMLString
The text in the comment.
text
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.comment.

A comment.

public void
doctypeDecl(String
The name of the root element.
rootElement
,
String
The public identifier if an external DTD or null if the external DTD is specified using SYSTEM.
publicId
,
String
The system identifier if an external DTD, null otherwise.
systemId
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.doctypeDecl.

Notifies of the presence of the DOCTYPE line in the document.

public void
emptyElement(QName
The name of the element.
element
,
XMLAttributes
The element attributes.
attributes
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.emptyElement.

An empty element.

public void
endCDATA(Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.endCDATA.

The end of a CDATA section.

public void
endDocument(Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.endDocument.

The end of the document.

public void
endElement(QName
The name of the element.
element
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.endElement.

The end of an element.

public void
endGeneralEntity(String
The name of the entity.
name
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.endGeneralEntity.

This method notifies the end of a general entity.

protected final void
expandEntityRef(Node parent, Node reference)

public XMLDocumentSource
public void
ignorableWhitespace(XMLString
The ignorable whitespace.
text
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.ignorableWhitespace.

Ignorable whitespace.

public static final void
isAttrValueWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator, NamedNodeMap attributes, Attr a, String value, boolean xml11Version)

NON-DOM: check if attribute value is well-formed

public static final void
isCDataWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator, String datavalue, boolean
= true if XML 1.1
isXML11Version
)

Check if CDATA section is well-formed

public static final void
isCommentWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator, String datavalue, boolean
= true if XML 1.1
isXML11Version
)

NON-DOM: check if value of the comment is well-formed

public static final void
isXMLCharWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator, String datavalue, boolean
= true if XML 1.1
isXML11Version
)

NON-DOM: check for valid XML characters as per the XML version

protected final void
pack-priv final String
protected void
normalizeDocument(CoreDocumentImpl document, DOMConfigurationImpl config)

Normalizes document.

protected Node

Returns:

the normalized Node
normalizeNode
(Node
Modified node or null. If node is returned, we need to normalize again starting on the node returned.
node
)

This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form.

private void
processDTD(String xmlVersion, String schemaLocation)

public void
processingInstruction(String
The target.
target
,
XMLString
The data or null if none specified.
data
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.processingInstruction.

A processing instruction.

public static final void
reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator, String message, short severity, String type)

Reports a DOM error to the user handler.

public void
public void
startCDATA(Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.startCDATA.

The start of a CDATA section.

public void
startDocument(XMLLocator
The document locator, or null if the document location cannot be reported during the parsing of this document. However, it is strongly recommended that a locator be supplied that can at least report the system identifier of the document.
locator
,
String
The auto-detected IANA encoding name of the entity stream. This value will be null in those situations where the entity encoding is not auto-detected (e.g. internal entities or a document entity that is parsed from a java.io.Reader).
encoding
,
NamespaceContext
The namespace context in effect at the start of this document. This object represents the current context. Implementors of this class are responsible for copying the namespace bindings from the the current context (and its parent contexts) if that information is important.
namespaceContext
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.startDocument.

The start of the document.

public void
startElement(QName
The name of the element.
element
,
XMLAttributes
The element attributes.
attributes
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.startElement.

The start of an element.

public void
startGeneralEntity(String
The name of the general entity.
name
,
XMLResourceIdentifier
The resource identifier.
identifier
,
String
The auto-detected IANA encoding name of the entity stream. This value will be null in those situations where the entity encoding is not auto-detected (e.g. internal entities or a document entity that is parsed from a java.io.Reader).
encoding
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.startGeneralEntity.

This method notifies the start of a general entity.

public void
textDecl(String
The XML version, or null if not specified.
version
,
String
The IANA encoding name of the entity.
encoding
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.textDecl.

Notifies of the presence of a TextDecl line in an entity.

protected final void
updateQName(Node node, QName qname)

public void
xmlDecl(String
The XML version.
version
,
String
The IANA encoding name of the document, or null if not specified.
encoding
,
String
The standalone value, or null if not specified.
standalone
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.xmlDecl.

Notifies of the presence of an XMLDecl line in the document.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait