org.apache.xerces.parsers

Class DOMParser

Implemented Interfaces:
org.apache.xerces.xni.XMLDocumentHandler, org.apache.xerces.xni.XMLDTDContentModelHandler, org.apache.xerces.xni.XMLDTDHandler

public class DOMParser
extends AbstractDOMParser

This is the main Xerces DOM parser class. It uses the abstract DOM parser with a document scanner, a dtd scanner, and a validator, as well as a grammar pool.
Version:
$Id: DOMParser.java 320531 2005-06-24 02:33:43Z mrglavas $
Authors:
Arnaud Le Hors, IBM
Andy Clark, IBM

Field Summary

protected static String
SYMBOL_TABLE
Property identifier: symbol table.
protected static String
USE_ENTITY_RESOLVER2
Feature identifier: EntityResolver2.
protected static String
XMLGRAMMAR_POOL
Property identifier: XML grammar pool.
protected boolean
fUseEntityResolver2
Use EntityResolver2.

Fields inherited from class org.apache.xerces.parsers.AbstractDOMParser

CORE_DOCUMENT_CLASS_NAME, CREATE_CDATA_NODES_FEATURE, CREATE_ENTITY_REF_NODES, CURRENT_ELEMENT_NODE, DEFAULT_DOCUMENT_CLASS_NAME, DEFER_NODE_EXPANSION, DOCUMENT_CLASS_NAME, INCLUDE_COMMENTS_FEATURE, INCLUDE_IGNORABLE_WHITESPACE, NAMESPACES, PSVI_DOCUMENT_CLASS_NAME, abort, fBaseURIStack, fCreateCDATANodes, fCreateEntityRefNodes, fCurrentCDATASection, fCurrentCDATASectionIndex, fCurrentEntityDecl, fCurrentNode, fCurrentNodeIndex, fDOMFilter, fDeferNodeExpansion, fDeferredDocumentImpl, fDeferredEntityDecl, fDocument, fDocumentClassName, fDocumentImpl, fDocumentIndex, fDocumentType, fDocumentTypeIndex, fErrorHandler, fFilterReject, fFirstChunk, fInCDATASection, fInDTD, fInDTDExternalSubset, fInEntityRef, fIncludeComments, fIncludeIgnorableWhitespace, fInternalSubset, fNamespaceAware, fRejectedElement, fRoot, fSkippedElemStack, fStorePSVI, fStringBuffer

Fields inherited from class org.apache.xerces.parsers.AbstractXMLDocumentParser

fDTDContentModelSource, fDTDSource, fDocumentSource, fInDTD

Fields inherited from class org.apache.xerces.parsers.XMLParser

ENTITY_RESOLVER, ERROR_HANDLER, fConfiguration

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

Fields inherited from interface org.apache.xerces.xni.XMLDTDHandler

CONDITIONAL_IGNORE, CONDITIONAL_INCLUDE

Constructor Summary

DOMParser()
Constructs a DOM parser using the dtd/xml schema parser configuration.
DOMParser(SymbolTable symbolTable)
Constructs a DOM parser using the specified symbol table.
DOMParser(SymbolTable symbolTable, org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool)
Constructs a DOM parser using the specified symbol table and grammar pool.
DOMParser(org.apache.xerces.xni.parser.XMLParserConfiguration config)
Constructs a DOM parser using the specified parser configuration.

Method Summary

org.xml.sax.EntityResolver
getEntityResolver()
Return the current entity resolver.
org.xml.sax.ErrorHandler
getErrorHandler()
Return the current error handler.
boolean
getFeature(String featureId)
Query the state of a feature.
Object
getProperty(String propertyId)
Query the value of a property.
org.apache.xerces.xni.parser.XMLParserConfiguration
getXMLParserConfiguration()
Returns this parser's XMLParserConfiguration.
void
parse(String systemId)
Parses the input source specified by the given system identifier.
void
parse(org.xml.sax.InputSource inputSource)
parse
void
setEntityResolver(org.xml.sax.EntityResolver resolver)
Sets the resolver used to resolve external entities.
void
setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Allow an application to register an error event handler.
void
setFeature(String featureId, boolean state)
Set the state of any feature in a SAX2 parser.
void
setProperty(String propertyId, Object value)
Set the value of any property in a SAX2 parser.

Methods inherited from class org.apache.xerces.parsers.AbstractDOMParser

abort, attributeDecl, characters, comment, createAttrNode, createElementNode, doctypeDecl, dropDocumentReferences, elementDecl, emptyElement, endAttlist, endCDATA, endConditional, endDTD, endDocument, endElement, endExternalSubset, endGeneralEntity, endParameterEntity, externalEntityDecl, getDocument, getDocumentClassName, handleBaseURI, handleBaseURI, ignorableWhitespace, ignoredCharacters, internalEntityDecl, notationDecl, processingInstruction, reset, setCharacterData, setDocumentClassName, setLocale, startAttlist, startCDATA, startConditional, startDTD, startDocument, startElement, startExternalSubset, startGeneralEntity, startParameterEntity, textDecl, unparsedEntityDecl, xmlDecl

Methods inherited from class org.apache.xerces.parsers.AbstractXMLDocumentParser

any, attributeDecl, characters, comment, doctypeDecl, element, elementDecl, empty, emptyElement, endAttlist, endCDATA, endConditional, endContentModel, endDTD, endDocument, endElement, endExternalSubset, endGeneralEntity, endGroup, endParameterEntity, externalEntityDecl, getDTDContentModelSource, getDTDSource, getDocumentSource, ignorableWhitespace, ignoredCharacters, internalEntityDecl, notationDecl, occurrence, pcdata, processingInstruction, reset, separator, setDTDContentModelSource, setDTDSource, setDocumentSource, startAttlist, startCDATA, startConditional, startContentModel, startDTD, startDocument, startElement, startExternalSubset, startGeneralEntity, startGroup, startParameterEntity, textDecl, unparsedEntityDecl, xmlDecl

Methods inherited from class org.apache.xerces.parsers.XMLParser

parse, reset

Field Details

SYMBOL_TABLE

protected static final String SYMBOL_TABLE
Property identifier: symbol table.

USE_ENTITY_RESOLVER2

protected static final String USE_ENTITY_RESOLVER2
Feature identifier: EntityResolver2.

XMLGRAMMAR_POOL

protected static final String XMLGRAMMAR_POOL
Property identifier: XML grammar pool.

fUseEntityResolver2

protected boolean fUseEntityResolver2
Use EntityResolver2.

Constructor Details

DOMParser

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

DOMParser

public DOMParser(SymbolTable symbolTable)
Constructs a DOM parser using the specified symbol table.

DOMParser

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

DOMParser

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

Method Details

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Return the current entity resolver.
Returns:
The current entity resolver, or null if none has been registered.

getErrorHandler

public org.xml.sax.ErrorHandler getErrorHandler()
Return the current error handler.
Returns:
The current error handler, or null if none has been registered.

getFeature

public boolean getFeature(String featureId)
            throws org.xml.sax.SAXNotRecognizedException,
                   org.xml.sax.SAXNotSupportedException
Query the state of a feature. Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.
Parameters:
featureId - The unique identifier (URI) of the feature being set.
Returns:
The current state of the feature.
Throws:
org.xml.sax.SAXNotRecognizedException - If the requested feature is not known.
org.xml.sax.SAXNotSupportedException - If the requested feature is known but not supported.

getProperty

public Object getProperty(String propertyId)
            throws org.xml.sax.SAXNotRecognizedException,
                   org.xml.sax.SAXNotSupportedException
Query the value of a property. Return the current value of a property in a SAX2 parser. The parser might not recognize the property.
Parameters:
propertyId - The unique identifier (URI) of the property being set.
Returns:
The current value of the property.
Throws:
org.xml.sax.SAXNotRecognizedException - If the requested property is not known.
org.xml.sax.SAXNotSupportedException - If the requested property is known but not supported.

getXMLParserConfiguration

public org.apache.xerces.xni.parser.XMLParserConfiguration getXMLParserConfiguration()
Returns this parser's XMLParserConfiguration.

parse

public void parse(String systemId)
            throws org.xml.sax.SAXException,
                   IOException
Parses the input source specified by the given system identifier.

This method is equivalent to the following:

     parse(new InputSource(systemId));
 
Parameters:
systemId - The system identifier (URI).
Throws:
org.xml.sax.SAXException - Throws exception on SAX error.

parse

public void parse(org.xml.sax.InputSource inputSource)
            throws org.xml.sax.SAXException,
                   IOException
parse
Parameters:
inputSource -
Throws:
org.xml.sax.SAXException -

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Sets the resolver used to resolve external entities. The EntityResolver interface supports resolution of public and system identifiers.
Parameters:
resolver - The new entity resolver. Passing a null value will uninstall the currently installed resolver.

setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Allow an application to register an error event handler.

If the application does not register an error handler, all error events reported by the SAX parser will be silently ignored; however, normal processing may not continue. It is highly recommended that all SAX applications implement an error handler to avoid unexpected bugs.

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Parameters:
errorHandler - The error handler.

setFeature

public void setFeature(String featureId,
                       boolean state)
            throws org.xml.sax.SAXNotRecognizedException,
                   org.xml.sax.SAXNotSupportedException
Set the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.
Parameters:
featureId - The unique identifier (URI) of the feature.
state - The requested state of the feature (true or false).
Throws:
org.xml.sax.SAXNotRecognizedException - If the requested feature is not known.
org.xml.sax.SAXNotSupportedException - If the requested feature is known, but the requested state is not supported.

setProperty

public void setProperty(String propertyId,
                        Object value)
            throws org.xml.sax.SAXNotRecognizedException,
                   org.xml.sax.SAXNotSupportedException
Set the value of any property in a SAX2 parser. The parser might not recognize the property, and if it does recognize it, it might not support the requested value.
Parameters:
propertyId - The unique identifier (URI) of the property being set.
value - The value to which the property is being set.
Throws:
org.xml.sax.SAXNotRecognizedException - If the requested property is not known.
org.xml.sax.SAXNotSupportedException - If the requested property is known, but the requested value is not supported.

Copyright B) 1999-2006 The Apache Software Foundation. All Rights Reserved.