org.apache.xerces.parsers
Class DOMBuilderImpl

java.lang.Object
  |
  +--org.apache.xerces.parsers.XMLParser
        |
        +--org.apache.xerces.parsers.AbstractXMLDocumentParser
              |
              +--org.apache.xerces.parsers.AbstractDOMParser
                    |
                    +--org.apache.xerces.parsers.DOMBuilderImpl
All Implemented Interfaces:
org.apache.xerces.dom3.ls.DOMBuilder, org.apache.xerces.xni.XMLDocumentHandler, org.apache.xerces.xni.XMLDTDContentModelHandler, org.apache.xerces.xni.XMLDTDHandler
Direct Known Subclasses:
DOMASBuilderImpl

public class DOMBuilderImpl
extends AbstractDOMParser
implements org.apache.xerces.dom3.ls.DOMBuilder

This is Xerces DOM Builder class. It uses the abstract DOM parser with a document scanner, a dtd scanner, and a validator, as well as a grammar pool.

Author:
Pavani Mukthipudi, Sun Microsystems Inc., Elena Litani, IBM, Rahul Srivastava, Sun Microsystems Inc.

Field Summary
protected static java.lang.String CHARSET_OVERRIDES_XML_ENCODING
          Feature id: charset overrides xml encoding.
protected static java.lang.String COMMENTS
          Feature id: comments.
protected static java.lang.String CREATE_ENTITY_NODES
          Feature id: create entity nodes.
protected static java.lang.String CREATE_ENTITY_REFERENCE_NODES
          Feature id: create entity ref nodes.
protected static java.lang.String DATATYPE_NORMALIZATION
          Feature id: datatype normalization.
protected static java.lang.String DYNAMIC_VALIDATION
          Dynamic validation
protected static java.lang.String EXTERNAL_DTD_SUBSET
          Feature id: external dtd subset.
protected static java.lang.String EXTERNAL_GENERAL_ENTITIES
          Feature id: external general entities.
protected static java.lang.String EXTERNAL_GENERAL_ENTITIES_FEATURE
          Feature id: external general entities.
protected static java.lang.String EXTERNAL_PARAMETER_ENTITIES
          Feature id: external parameter entities.
protected static java.lang.String EXTERNAL_PARAMETER_ENTITIES_FEATURE
          Feature id: external parameter entities.
protected static java.lang.String LOAD_AS_INFOSET
          Feature id: load as infoset.
protected static java.lang.String LOAD_EXTERNAL_DTD_FEATURE
          Feature id: load external dtd.
protected static java.lang.String NAMESPACE_DECLARATIONS
          Feature id: namespace declarations.
protected static java.lang.String SUPPORTED_MEDIATYPES_ONLY
          Feature id: supported mediatypes only.
protected static java.lang.String VALIDATE_AGAINST_DTD
          Feature id: validate against dtd.
protected static java.lang.String VALIDATE_IF_SCHEMA
          Feature id: validate if schema.
protected static java.lang.String VALIDATION
          Feature id: validation.
protected static java.lang.String VALIDATION_FEATURE
          Feature id: validation.
protected static java.lang.String WHITESPACE_IN_ELEMENT_CONTENT
          Feature id: whitespace in element content.
protected static java.lang.String XMLSCHEMA
          XML Schema validation
 
Fields inherited from class org.apache.xerces.parsers.AbstractDOMParser
CREATE_CDATA_NODES_FEATURE, CREATE_ENTITY_REF_NODES, CURRENT_ELEMENT_NODE, DEFAULT_DOCUMENT_CLASS_NAME, DEFER_NODE_EXPANSION, DOCUMENT_CLASS_NAME, fCreateCDATANodes, fCreateEntityRefNodes, fCurrentCDATASection, fCurrentCDATASectionIndex, fCurrentNode, fCurrentNodeIndex, fDeferNodeExpansion, fDeferredDocumentImpl, fDocument, fDocumentClassName, fDocumentImpl, fDocumentIndex, fDocumentType, fDocumentTypeIndex, fInCDATASection, fIncludeComments, fIncludeIgnorableWhitespace, fInDocument, fInDTDExternalSubset, fInternalSubset, fNamespaceAware, fNormalizeData, INCLUDE_COMMENTS_FEATURE, INCLUDE_IGNORABLE_WHITESPACE, NAMESPACES, NORMALIZE_DATA
 
Fields inherited from class org.apache.xerces.parsers.AbstractXMLDocumentParser
fInDTD
 
Fields inherited from class org.apache.xerces.parsers.XMLParser
ENTITY_RESOLVER, ERROR_HANDLER, fConfiguration
 
Fields inherited from interface org.apache.xerces.dom3.ls.DOMBuilder
ACTION_APPEND, ACTION_INSERT_AFTER, ACTION_INSERT_BEFORE, ACTION_REPLACE
 
Fields inherited from interface org.apache.xerces.xni.XMLDTDHandler
CONDITIONAL_IGNORE, CONDITIONAL_INCLUDE
 
Fields inherited from interface org.apache.xerces.xni.XMLDTDContentModelHandler
OCCURS_ONE_OR_MORE, OCCURS_ZERO_OR_MORE, OCCURS_ZERO_OR_ONE, SEPARATOR_CHOICE, SEPARATOR_SEQUENCE
 
Constructor Summary
DOMBuilderImpl()
          Constructs a DOM Builder using the dtd/xml schema parser configuration.
DOMBuilderImpl(SymbolTable symbolTable)
          Constructs a DOM Builder using the specified symbol table.
DOMBuilderImpl(SymbolTable symbolTable, org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool)
          Constructs a DOM Builder using the specified symbol table and grammar pool.
DOMBuilderImpl(org.apache.xerces.xni.parser.XMLParserConfiguration config)
          Constructs a DOM Builder using the specified parser configuration.
 
Method Summary
 boolean canSetFeature(java.lang.String name, boolean state)
          Query whether setting a feature to a specific value is supported.
 org.apache.xerces.dom3.ls.DOMEntityResolver getEntityResolver()
          If a DOMEntityResolver has been specified, each time a reference to an external entity is encountered the DOMBuilder will pass the public and system IDs to the entity resolver, which can then specify the actual source of the entity.
 org.apache.xerces.dom3.DOMErrorHandler getErrorHandler()
          In the event that an error is encountered in the XML document being parsed, the DOMDcoumentBuilder will call back to the errorHandler with the error information.
 boolean getFeature(java.lang.String name)
          Look up the value of a feature.
 org.apache.xerces.dom3.ls.DOMBuilderFilter getFilter()
          When the application provides a filter, the parser will call out to the filter at the completion of the construction of each Element node.
 org.w3c.dom.Document parse(org.apache.xerces.dom3.ls.DOMInputSource is)
          Parse an XML document from a resource identified by an DOMInputSource.
 org.w3c.dom.Document parseURI(java.lang.String uri)
          Parse an XML document from a location identified by an URI reference.
 void parseWithContext(org.apache.xerces.dom3.ls.DOMInputSource is, org.w3c.dom.Node cnode, short action)
          Parse an XML document or fragment from a resource identified by an DOMInputSource and insert the content into an existing document at the position epcified with the contextNode and action arguments.
 void reset()
          Resets the parser state.
 void setEntityResolver(org.apache.xerces.dom3.ls.DOMEntityResolver entityResolver)
          If a DOMEntityResolver has been specified, each time a reference to an external entity is encountered the DOMBuilder will pass the public and system IDs to the entity resolver, which can then specify the actual source of the entity.
 void setErrorHandler(org.apache.xerces.dom3.DOMErrorHandler errorHandler)
          In the event that an error is encountered in the XML document being parsed, the DOMDcoumentBuilder will call back to the errorHandler with the error information.
 void setFeature(java.lang.String name, boolean state)
          Set the state of a feature.
 void setFilter(org.apache.xerces.dom3.ls.DOMBuilderFilter filter)
          When the application provides a filter, the parser will call out to the filter at the completion of the construction of each Element node.
 
Methods inherited from class org.apache.xerces.parsers.AbstractDOMParser
attributeDecl, characters, comment, createAttrNode, createElementNode, doctypeDecl, elementDecl, endCDATA, endDocument, endDTD, endElement, endExternalSubset, endGeneralEntity, endPrefixMapping, externalEntityDecl, getDocument, getDocumentClassName, ignorableWhitespace, internalEntityDecl, notationDecl, processingInstruction, setDocumentClassName, startCDATA, startDocument, startDTD, startElement, startExternalSubset, startGeneralEntity, textDecl, unparsedEntityDecl, xmlDecl
 
Methods inherited from class org.apache.xerces.parsers.AbstractXMLDocumentParser
any, element, empty, emptyElement, endAttlist, endConditional, endContentModel, endGroup, endParameterEntity, ignoredCharacters, occurrence, pcdata, separator, startAttlist, startConditional, startContentModel, startGroup, startParameterEntity, startPrefixMapping
 
Methods inherited from class org.apache.xerces.parsers.XMLParser
parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACE_DECLARATIONS

protected static final java.lang.String NAMESPACE_DECLARATIONS
Feature id: namespace declarations.

VALIDATION

protected static final java.lang.String VALIDATION
Feature id: validation.

EXTERNAL_PARAMETER_ENTITIES

protected static final java.lang.String EXTERNAL_PARAMETER_ENTITIES
Feature id: external parameter entities.

EXTERNAL_GENERAL_ENTITIES

protected static final java.lang.String EXTERNAL_GENERAL_ENTITIES
Feature id: external general entities.

EXTERNAL_DTD_SUBSET

protected static final java.lang.String EXTERNAL_DTD_SUBSET
Feature id: external dtd subset.

VALIDATE_IF_SCHEMA

protected static final java.lang.String VALIDATE_IF_SCHEMA
Feature id: validate if schema.

VALIDATE_AGAINST_DTD

protected static final java.lang.String VALIDATE_AGAINST_DTD
Feature id: validate against dtd.

DATATYPE_NORMALIZATION

protected static final java.lang.String DATATYPE_NORMALIZATION
Feature id: datatype normalization.

CREATE_ENTITY_REFERENCE_NODES

protected static final java.lang.String CREATE_ENTITY_REFERENCE_NODES
Feature id: create entity ref nodes.

CREATE_ENTITY_NODES

protected static final java.lang.String CREATE_ENTITY_NODES
Feature id: create entity nodes.

WHITESPACE_IN_ELEMENT_CONTENT

protected static final java.lang.String WHITESPACE_IN_ELEMENT_CONTENT
Feature id: whitespace in element content.

COMMENTS

protected static final java.lang.String COMMENTS
Feature id: comments.

CHARSET_OVERRIDES_XML_ENCODING

protected static final java.lang.String CHARSET_OVERRIDES_XML_ENCODING
Feature id: charset overrides xml encoding.

LOAD_AS_INFOSET

protected static final java.lang.String LOAD_AS_INFOSET
Feature id: load as infoset.

SUPPORTED_MEDIATYPES_ONLY

protected static final java.lang.String SUPPORTED_MEDIATYPES_ONLY
Feature id: supported mediatypes only.

VALIDATION_FEATURE

protected static final java.lang.String VALIDATION_FEATURE
Feature id: validation.

EXTERNAL_PARAMETER_ENTITIES_FEATURE

protected static final java.lang.String EXTERNAL_PARAMETER_ENTITIES_FEATURE
Feature id: external parameter entities.

EXTERNAL_GENERAL_ENTITIES_FEATURE

protected static final java.lang.String EXTERNAL_GENERAL_ENTITIES_FEATURE
Feature id: external general entities.

LOAD_EXTERNAL_DTD_FEATURE

protected static final java.lang.String LOAD_EXTERNAL_DTD_FEATURE
Feature id: load external dtd.

XMLSCHEMA

protected static final java.lang.String XMLSCHEMA
XML Schema validation

DYNAMIC_VALIDATION

protected static final java.lang.String DYNAMIC_VALIDATION
Dynamic validation
Constructor Detail

DOMBuilderImpl

public DOMBuilderImpl()
Constructs a DOM Builder using the dtd/xml schema parser configuration.

DOMBuilderImpl

public DOMBuilderImpl(org.apache.xerces.xni.parser.XMLParserConfiguration config)
Constructs a DOM Builder using the specified parser configuration.

DOMBuilderImpl

public DOMBuilderImpl(SymbolTable symbolTable)
Constructs a DOM Builder using the specified symbol table.

DOMBuilderImpl

public DOMBuilderImpl(SymbolTable symbolTable,
                      org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool)
Constructs a DOM Builder using the specified symbol table and grammar pool.
Method Detail

reset

public void reset()
Resets the parser state.
Overrides:
reset in class AbstractDOMParser
Throws:
SAXException - Thrown on initialization error.

getEntityResolver

public org.apache.xerces.dom3.ls.DOMEntityResolver getEntityResolver()
If a DOMEntityResolver has been specified, each time a reference to an external entity is encountered the DOMBuilder will pass the public and system IDs to the entity resolver, which can then specify the actual source of the entity.
Specified by:
getEntityResolver in interface org.apache.xerces.dom3.ls.DOMBuilder

setEntityResolver

public void setEntityResolver(org.apache.xerces.dom3.ls.DOMEntityResolver entityResolver)
If a DOMEntityResolver has been specified, each time a reference to an external entity is encountered the DOMBuilder will pass the public and system IDs to the entity resolver, which can then specify the actual source of the entity.
Specified by:
setEntityResolver in interface org.apache.xerces.dom3.ls.DOMBuilder

getErrorHandler

public org.apache.xerces.dom3.DOMErrorHandler getErrorHandler()
In the event that an error is encountered in the XML document being parsed, the DOMDcoumentBuilder will call back to the errorHandler with the error information. When the document loading process calls the error handler the node closest to where the error occured is passed to the error handler if the implementation, if the implementation is unable to pass the node where the error occures the document Node is passed to the error handler. Mutations to the document from within an error handler will result in implementation dependent behavour.
Specified by:
getErrorHandler in interface org.apache.xerces.dom3.ls.DOMBuilder

setErrorHandler

public void setErrorHandler(org.apache.xerces.dom3.DOMErrorHandler errorHandler)
In the event that an error is encountered in the XML document being parsed, the DOMDcoumentBuilder will call back to the errorHandler with the error information. When the document loading process calls the error handler the node closest to where the error occured is passed to the error handler if the implementation, if the implementation is unable to pass the node where the error occures the document Node is passed to the error handler. Mutations to the document from within an error handler will result in implementation dependent behavour.
Specified by:
setErrorHandler in interface org.apache.xerces.dom3.ls.DOMBuilder

getFilter

public org.apache.xerces.dom3.ls.DOMBuilderFilter getFilter()
When the application provides a filter, the parser will call out to the filter at the completion of the construction of each Element node. The filter implementation can choose to remove the element from the document being constructed (unless the element is the document element) or to terminate the parse early. If the document is being validated when it's loaded the validation happens before the filter is called.
Specified by:
getFilter in interface org.apache.xerces.dom3.ls.DOMBuilder

setFilter

public void setFilter(org.apache.xerces.dom3.ls.DOMBuilderFilter filter)
When the application provides a filter, the parser will call out to the filter at the completion of the construction of each Element node. The filter implementation can choose to remove the element from the document being constructed (unless the element is the document element) or to terminate the parse early. If the document is being validated when it's loaded the validation happens before the filter is called.
Specified by:
setFilter in interface org.apache.xerces.dom3.ls.DOMBuilder

setFeature

public void setFeature(java.lang.String name,
                       boolean state)
                throws org.w3c.dom.DOMException
Set the state of a feature.
The feature name has the same form as a DOM hasFeature string.
It is possible for a DOMBuilder to recognize a feature name but to be unable to set its value.
Specified by:
setFeature in interface org.apache.xerces.dom3.ls.DOMBuilder
Parameters:
name - The feature name.
state - The requested state of the feature (true or false).
Throws:
org.w3c.dom.DOMException - Raise a NOT_SUPPORTED_ERR exception when the DOMBuilder recognizes the feature name but cannot set the requested value.
Raise a NOT_FOUND_ERR When the DOMBuilder does not recognize the feature name.

canSetFeature

public boolean canSetFeature(java.lang.String name,
                             boolean state)
Query whether setting a feature to a specific value is supported.
The feature name has the same form as a DOM hasFeature string.
Specified by:
canSetFeature in interface org.apache.xerces.dom3.ls.DOMBuilder
Parameters:
name - The feature name, which is a DOM has-feature style string.
state - The requested state of the feature (true or false).
Returns:
true if the feature could be successfully set to the specified value, or false if the feature is not recognized or the requested value is not supported. The value of the feature itself is not changed.

getFeature

public boolean getFeature(java.lang.String name)
                   throws org.w3c.dom.DOMException
Look up the value of a feature.
The feature name has the same form as a DOM hasFeature string
Specified by:
getFeature in interface org.apache.xerces.dom3.ls.DOMBuilder
Parameters:
name - The feature name, which is a string with DOM has-feature syntax.
Returns:
The current state of the feature (true or false).
Throws:
org.w3c.dom.DOMException - Raise a NOT_FOUND_ERR When the DOMBuilder does not recognize the feature name.

parseURI

public org.w3c.dom.Document parseURI(java.lang.String uri)
                              throws java.lang.Exception
Parse an XML document from a location identified by an URI reference. If the URI contains a fragment identifier (see section 4.1 in ), the behavior is not defined by this specification.
Specified by:
parseURI in interface org.apache.xerces.dom3.ls.DOMBuilder
Parameters:
uri - The location of the XML document to be read.
Returns:
If the DOMBuilder is a synchronous DOMBuilder the newly created and populated Document is returned. If the DOMBuilder is asynchronous then null is returned since the document object is not yet parsed when this method returns.
Throws:
DOMSystemException - Exceptions raised by parseURI originate with the installed ErrorHandler, and thus depend on the implementation of the DOMErrorHandler interfaces. The default error handlers will raise a DOMSystemException if any form I/O or other system error occurs during the parse, but application defined error handlers are not required to do so.

parse

public org.w3c.dom.Document parse(org.apache.xerces.dom3.ls.DOMInputSource is)
                           throws java.lang.Exception
Parse an XML document from a resource identified by an DOMInputSource.
Specified by:
parse in interface org.apache.xerces.dom3.ls.DOMBuilder
Parameters:
is - The DOMInputSource from which the source document is to be read.
Returns:
If the DOMBuilder is a synchronous DOMBuilder the newly created and populated Document is returned. If the DOMBuilder is asynchronous then null is returned since the document object is not yet parsed when this method returns.
Throws:
DOMSystemException - Exceptions raised by parse originate with the installed ErrorHandler, and thus depend on the implementation of the DOMErrorHandler interfaces. The default ErrorHandlers will raise a DOMSystemException if any form I/O or other system error occurs during the parse, but application defined ErrorHandlers are not required to do so.

parseWithContext

public void parseWithContext(org.apache.xerces.dom3.ls.DOMInputSource is,
                             org.w3c.dom.Node cnode,
                             short action)
                      throws org.w3c.dom.DOMException
Parse an XML document or fragment from a resource identified by an DOMInputSource and insert the content into an existing document at the position epcified with the contextNode and action arguments. When parsing the input stream the context node is used for resolving unbound namespace prefixes.
Specified by:
parseWithContext in interface org.apache.xerces.dom3.ls.DOMBuilder
Parameters:
is - The DOMInputSource from which the source document is to be read.
cnode - The Node that is used as the context for the data that is being parsed.
action - This parameter describes which action should be taken between the new set of node being inserted and the existing children of the context node. The set of possible actions is defined above.
Throws:
org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR: Thrown if this action results in an invalid hierarchy (i.e. a Document with more than one document element).


Copyright © 1999-2002 Apache XML Project. All Rights Reserved.