BEA Systems, Inc.

WebLogic Server 8.1 API Reference

weblogic.apache.xerces.dom
Class DOMNormalizer

java.lang.Object
  |
  +--weblogic.apache.xerces.dom.DOMNormalizer

public class DOMNormalizer
extends java.lang.Object
implements XMLGrammarPool

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). NOTE: the implementation is experimental and methods, functionality can be modified or removed in the future.


Inner Class Summary
protected  class DOMNormalizer.XMLAttributesProxy
           
 
Field Summary
protected static boolean DEBUG
          Debug namespace fix up algorithm
protected static boolean DEBUG_ND
          Debug normalize document
protected static java.lang.String ERROR_HANDLER
          Property identifier: error handler.
protected  java.util.Vector fAttributeList
          list of attributes
protected  DOMNormalizer.XMLAttributesProxy fAttrProxy
           
protected  CoreDocumentImpl fDocument
           
protected  DOMErrorImpl fDOMError
          DOM Error object
protected  org.apache.xerces.dom3.DOMErrorHandler fErrorHandler
          error handler
protected  Grammar[] fGrammarPool
           
protected  NamespaceSupport fLocalNSBinder
          stores all namespace bindings on the current element
protected  DOMLocatorImpl fLocator
          DOM Locator - for namespace fixup algorithm
protected  NamespaceSupport fNamespaceBinder
          stores namespaces in scope
protected  int fNamespaceCounter
           
protected  boolean fNamespaceValidation
           
protected  QName fQName
           
protected  SymbolTable fSymbolTable
          symbol table
protected  RevalidationHandler fValidationHandler
          Validation handler represents validator instance.
protected static java.lang.String PREFIX
          prefix added by namespace fixup algorithm should follow a pattern "NS" + index
protected static java.lang.String SYMBOL_TABLE
          Property identifier: symbol table.
 
Constructor Summary
DOMNormalizer()
           
 
Method Summary
protected  void addNamespaceDecl(java.lang.String prefix, java.lang.String uri, ElementImpl element)
          Adds a namespace attribute or replaces the value of existing namespace attribute with the given prefix and value for URI.
 void cacheGrammars(java.lang.String grammarType, Grammar[] grammars)
           
 void clear()
           
protected  void expandEntityRef(org.w3c.dom.Node node, org.w3c.dom.Node parent, org.w3c.dom.Node reference)
           
 void lockPool()
           
protected  org.apache.xerces.dom3.DOMError modifyDOMError(java.lang.String message, short severity, org.w3c.dom.Node node)
           
protected  void namespaceFixUp(ElementImpl element, AttributeMap attributes)
           
protected  void normalizeDocument(CoreDocumentImpl document)
          Normalizes document.
protected  org.w3c.dom.Node normalizeNode(org.w3c.dom.Node node)
          This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form.
protected  boolean removeDefault(org.w3c.dom.Attr attribute, AttributeMap attrMap)
           
protected  void reset(XMLComponentManager componentManager)
           
 Grammar retrieveGrammar(XMLGrammarDescription desc)
           
 Grammar[] retrieveInitialGrammarSet(java.lang.String grammarType)
           
protected  void setValidationHandler(RevalidationHandler validator)
           
 void unlockPool()
           
protected  void updateQName(org.w3c.dom.Node node, QName qname)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_ND

protected static final boolean DEBUG_ND
Debug normalize document

DEBUG

protected static final boolean DEBUG
Debug namespace fix up algorithm

PREFIX

protected static final java.lang.String PREFIX
prefix added by namespace fixup algorithm should follow a pattern "NS" + index

ERROR_HANDLER

protected static final java.lang.String ERROR_HANDLER
Property identifier: error handler.

SYMBOL_TABLE

protected static final java.lang.String SYMBOL_TABLE
Property identifier: symbol table.

fDocument

protected CoreDocumentImpl fDocument

fAttrProxy

protected final DOMNormalizer.XMLAttributesProxy fAttrProxy

fQName

protected final QName fQName

fValidationHandler

protected RevalidationHandler fValidationHandler
Validation handler represents validator instance.

fSymbolTable

protected SymbolTable fSymbolTable
symbol table

fErrorHandler

protected org.apache.xerces.dom3.DOMErrorHandler fErrorHandler
error handler

fNamespaceCounter

protected int fNamespaceCounter

fNamespaceValidation

protected boolean fNamespaceValidation

fNamespaceBinder

protected final NamespaceSupport fNamespaceBinder
stores namespaces in scope

fLocalNSBinder

protected final NamespaceSupport fLocalNSBinder
stores all namespace bindings on the current element

fAttributeList

protected final java.util.Vector fAttributeList
list of attributes

fDOMError

protected final DOMErrorImpl fDOMError
DOM Error object

fLocator

protected final DOMLocatorImpl fLocator
DOM Locator - for namespace fixup algorithm

fGrammarPool

protected final Grammar[] fGrammarPool
Constructor Detail

DOMNormalizer

public DOMNormalizer()
Method Detail

reset

protected void reset(XMLComponentManager componentManager)


setValidationHandler

protected void setValidationHandler(RevalidationHandler validator)


normalizeDocument

protected void normalizeDocument(CoreDocumentImpl document)
Normalizes document. Note: reset() must be called before this method.


normalizeNode

protected org.w3c.dom.Node normalizeNode(org.w3c.dom.Node node)
This method 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.

Parameters:
node - Modified node or null. If node is returned, we need to normalize again starting on the node returned.
Returns:
 

expandEntityRef

protected final void expandEntityRef(org.w3c.dom.Node node,
                                     org.w3c.dom.Node parent,
                                     org.w3c.dom.Node reference)


namespaceFixUp

protected final void namespaceFixUp(ElementImpl element,
                                    AttributeMap attributes)


addNamespaceDecl

protected final void addNamespaceDecl(java.lang.String prefix,
                                      java.lang.String uri,
                                      ElementImpl element)
Adds a namespace attribute or replaces the value of existing namespace attribute with the given prefix and value for URI. In case prefix is empty will add/update default namespace declaration.

Parameters:
prefix -  
uri -  
Throws:
IOException -  

removeDefault

protected final boolean removeDefault(org.w3c.dom.Attr attribute,
                                      AttributeMap attrMap)


modifyDOMError

protected final org.apache.xerces.dom3.DOMError modifyDOMError(java.lang.String message,
                                                               short severity,
                                                               org.w3c.dom.Node node)


updateQName

protected final void updateQName(org.w3c.dom.Node node,
                                 QName qname)


retrieveInitialGrammarSet

public Grammar[] retrieveInitialGrammarSet(java.lang.String grammarType)
Specified by:
retrieveInitialGrammarSet in interface XMLGrammarPool


cacheGrammars

public void cacheGrammars(java.lang.String grammarType,
                          Grammar[] grammars)
Specified by:
cacheGrammars in interface XMLGrammarPool


retrieveGrammar

public Grammar retrieveGrammar(XMLGrammarDescription desc)
Specified by:
retrieveGrammar in interface XMLGrammarPool


lockPool

public void lockPool()
Specified by:
lockPool in interface XMLGrammarPool


unlockPool

public void unlockPool()
Specified by:
unlockPool in interface XMLGrammarPool


clear

public void clear()
Specified by:
clear in interface XMLGrammarPool


Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs81