/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2000-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* 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.
*
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
* @version $Id: DOMParser.java,v 1.7 2010-11-01 04:40:09 joehw Exp $
*/
public class DOMParser
extends AbstractDOMParser {
//
// Constants
//
// features
/** Feature identifier: EntityResolver2. */
// recognized features:
};
// properties
/** Property identifier: symbol table. */
/** Property identifier: XML grammar pool. */
/** Recognized properties. */
};
//
// Data
//
// features
/** Use EntityResolver2. */
protected boolean fUseEntityResolver2 = true;
//
// Constructors
//
/**
* Constructs a DOM parser using the specified parser configuration.
*/
super(config);
} // <init>(XMLParserConfiguration)
/**
*/
public DOMParser() {
} // <init>()
/**
* Constructs a DOM parser using the specified symbol table.
*/
this(symbolTable, null);
} // <init>(SymbolTable)
/**
* Constructs a DOM parser using the specified symbol table and
* grammar pool.
*/
super(new XIncludeAwareParserConfiguration());
// set properties
if (symbolTable != null) {
}
if (grammarPool != null) {
}
} // <init>(SymbolTable,XMLGrammarPool)
//
// XMLReader methods
//
/**
* Parses the input source specified by the given system identifier.
* <p>
* This method is equivalent to the following:
* <pre>
* parse(new InputSource(systemId));
* </pre>
*
* @param systemId The system identifier (URI).
*
* @exception org.xml.sax.SAXException Throws exception on SAX error.
* @exception java.io.IOException Throws exception on i/o error.
*/
// parse document
try {
}
// wrap XNI exceptions as SAX exceptions
catch (XMLParseException e) {
// must be a parser exception; mine it for locator info and throw
// a SAXParseException
}
if (ex instanceof SAXException) {
// why did we create an XMLParseException?
throw (SAXException)ex;
}
if (ex instanceof IOException) {
throw (IOException)ex;
}
throw new SAXException(ex);
}
catch (XNIException e) {
e.printStackTrace();
throw new SAXException(e.getMessage());
}
if (ex instanceof SAXException) {
throw (SAXException)ex;
}
if (ex instanceof IOException) {
throw (IOException)ex;
}
throw new SAXException(ex);
}
} // parse(String)
/**
* parse
*
* @param inputSource
*
* @exception org.xml.sax.SAXException
* @exception java.io.IOException
*/
throws SAXException, IOException {
// parse document
try {
null);
}
// wrap XNI exceptions as SAX exceptions
catch (XMLParseException e) {
// must be a parser exception; mine it for locator info and throw
// a SAXParseException
}
if (ex instanceof SAXException) {
// why did we create an XMLParseException?
throw (SAXException)ex;
}
if (ex instanceof IOException) {
throw (IOException)ex;
}
throw new SAXException(ex);
}
catch (XNIException e) {
throw new SAXException(e.getMessage());
}
if (ex instanceof SAXException) {
throw (SAXException)ex;
}
if (ex instanceof IOException) {
throw (IOException)ex;
}
throw new SAXException(ex);
}
} // parse(InputSource)
/**
* Sets the resolver used to resolve external entities. The EntityResolver
* interface supports resolution of public and system identifiers.
*
* @param resolver The new entity resolver. Passing a null value will
* uninstall the currently installed resolver.
*/
try {
if (xer instanceof EntityResolver2Wrapper) {
}
else {
}
}
else {
if (xer instanceof EntityResolverWrapper) {
}
else {
new EntityResolverWrapper(resolver));
}
}
}
catch (XMLConfigurationException e) {
// do nothing
}
} // setEntityResolver(EntityResolver)
/**
* Return the current entity resolver.
*
* @return The current entity resolver, or null if none
* has been registered.
* @see #setEntityResolver
*/
try {
if (xmlEntityResolver != null) {
if (xmlEntityResolver instanceof EntityResolverWrapper) {
}
else if (xmlEntityResolver instanceof EntityResolver2Wrapper) {
}
}
}
catch (XMLConfigurationException e) {
// do nothing
}
return entityResolver;
} // getEntityResolver():EntityResolver
/**
* Allow an application to register an error event handler.
*
* <p>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.</p>
*
* <p>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.</p>
*
* @param errorHandler The error handler.
* @exception java.lang.NullPointerException If the handler
* argument is null.
* @see #getErrorHandler
*/
try {
if (xeh instanceof ErrorHandlerWrapper) {
}
else {
new ErrorHandlerWrapper(errorHandler));
}
}
catch (XMLConfigurationException e) {
// do nothing
}
} // setErrorHandler(ErrorHandler)
/**
* Return the current error handler.
*
* @return The current error handler, or null if none
* has been registered.
* @see #setErrorHandler
*/
try {
if (xmlErrorHandler != null &&
xmlErrorHandler instanceof ErrorHandlerWrapper) {
}
}
catch (XMLConfigurationException e) {
// do nothing
}
return errorHandler;
} // getErrorHandler():ErrorHandler
/**
* 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.
*
* @param featureId The unique identifier (URI) of the feature.
* @param state The requested state of the feature (true or false).
*
* @exception SAXNotRecognizedException If the
* requested feature is not known.
* @exception SAXNotSupportedException If the
* requested feature is known, but the requested
* state is not supported.
*/
try {
// controls whether the methods of an object implementing
// org.xml.sax.ext.EntityResolver2 will be used by the parser.
//
if (state != fUseEntityResolver2) {
// Refresh EntityResolver wrapper.
}
return;
}
//
// Default handling
//
}
catch (XMLConfigurationException e) {
throw new SAXNotRecognizedException(
}
else {
throw new SAXNotSupportedException(
}
}
} // setFeature(String,boolean)
/**
* Query the state of a feature.
*
* Query the current state of any feature in a SAX2 parser. The
* parser might not recognize the feature.
*
* @param featureId The unique identifier (URI) of the feature
* being set.
* @return The current state of the feature.
* @exception org.xml.sax.SAXNotRecognizedException If the
* requested feature is not known.
* @exception SAXNotSupportedException If the
* requested feature is known but not supported.
*/
try {
// controls whether the methods of an object implementing
// org.xml.sax.ext.EntityResolver2 will be used by the parser.
//
return fUseEntityResolver2;
}
//
// Default handling
//
}
catch (XMLConfigurationException e) {
throw new SAXNotRecognizedException(
}
else {
throw new SAXNotSupportedException(
}
}
} // getFeature(String):boolean
/**
* 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.
*
* @param propertyId The unique identifier (URI) of the property
* being set.
* @param value The value to which the property is being set.
*
* @exception SAXNotRecognizedException If the
* requested property is not known.
* @exception SAXNotSupportedException If the
* requested property is known, but the requested
* value is not supported.
*/
try {
}
catch (XMLConfigurationException e) {
throw new SAXNotRecognizedException(
}
else {
throw new SAXNotSupportedException(
}
}
} // setProperty(String,Object)
/**
* Query the value of a property.
*
* Return the current value of a property in a SAX2 parser.
* The parser might not recognize the property.
*
* @param propertyId The unique identifier (URI) of the property
* being set.
* @return The current value of the property.
* @exception org.xml.sax.SAXNotRecognizedException If the
* requested property is not known.
* @exception SAXNotSupportedException If the
* requested property is known but not supported.
*/
boolean deferred = false;
try {
}
catch (XMLConfigurationException e){
// ignore
}
if (deferred) {
throw new SAXNotSupportedException("Current element node cannot be queried when node expansion is deferred.");
}
return (fCurrentNode!=null &&
}
try {
}
catch (XMLConfigurationException e) {
throw new SAXNotRecognizedException(
}
else {
throw new SAXNotSupportedException(
}
}
} // getProperty(String):Object
/**
* Returns this parser's XMLParserConfiguration.
*/
return fConfiguration;
} // getXMLParserConfiguration():XMLParserConfiguration
} // class DOMParser