FileDocCategorySizeDatePackage
DOMConfigurationImpl.javaAPI DocApache Xerces 3.0.150976Fri Sep 14 20:33:54 BST 2007org.apache.xerces.dom

DOMConfigurationImpl

public class DOMConfigurationImpl extends org.apache.xerces.util.ParserConfigurationSettings implements DOMConfiguration, org.apache.xerces.xni.parser.XMLParserConfiguration
Xerces implementation of DOMConfiguration that maintains a table of recognized parameters.
xerces.internal
author
Elena Litani, IBM
author
Neeraj Bajaj, Sun Microsystems.
version
$Id: DOMConfigurationImpl.java 530107 2007-04-18 17:59:54Z mrglavas $

Fields Summary
protected static final String
XML11_DATATYPE_VALIDATOR_FACTORY
protected static final String
XERCES_VALIDATION
Feature identifier: validation.
protected static final String
XERCES_NAMESPACES
Feature identifier: namespaces.
protected static final String
SCHEMA
protected static final String
SCHEMA_FULL_CHECKING
protected static final String
DYNAMIC_VALIDATION
protected static final String
NORMALIZE_DATA
protected static final String
SCHEMA_ELEMENT_DEFAULT
Feature identifier: send element default value via characters()
protected static final String
SEND_PSVI
sending psvi in the pipeline
protected static final String
GENERATE_SYNTHETIC_ANNOTATIONS
Feature: generate synthetic annotations
protected static final String
VALIDATE_ANNOTATIONS
Feature identifier: validate annotations
protected static final String
HONOUR_ALL_SCHEMALOCATIONS
Feature identifier: honour all schemaLocations
protected static final String
USE_GRAMMAR_POOL_ONLY
Feature identifier: use grammar pool only
protected static final String
DISALLOW_DOCTYPE_DECL_FEATURE
Feature identifier: load external DTD.
protected static final String
BALANCE_SYNTAX_TREES
Feature identifier: balance syntax trees.
protected static final String
WARN_ON_DUPLICATE_ATTDEF
Feature identifier: warn on duplicate attribute definition.
protected static final String
ENTITY_MANAGER
Property identifier: entity manager.
protected static final String
ERROR_REPORTER
Property identifier: error reporter.
protected static final String
XML_STRING
Property identifier: xml string.
protected static final String
SYMBOL_TABLE
Property identifier: symbol table.
protected static final String
GRAMMAR_POOL
Property id: Grammar pool
protected static final String
ERROR_HANDLER
Property identifier: error handler.
protected static final String
ENTITY_RESOLVER
Property identifier: entity resolver.
protected static final String
JAXP_SCHEMA_LANGUAGE
Property identifier: JAXP schema language / DOM schema-type.
protected static final String
JAXP_SCHEMA_SOURCE
Property identifier: JAXP schema source/ DOM schema-location.
protected static final String
DTD_VALIDATOR_PROPERTY
Property identifier: DTD validator.
protected static final String
DTD_VALIDATOR_FACTORY_PROPERTY
Property identifier: datatype validator factory.
protected static final String
VALIDATION_MANAGER
protected static final String
SCHEMA_LOCATION
Property identifier: schema location.
protected static final String
SCHEMA_NONS_LOCATION
Property identifier: no namespace schema location.
org.apache.xerces.xni.XMLDocumentHandler
fDocumentHandler
protected short
features
Normalization features
protected static final short
NAMESPACES
protected static final short
DTNORMALIZATION
protected static final short
ENTITIES
protected static final short
CDATA
protected static final short
SPLITCDATA
protected static final short
COMMENTS
protected static final short
VALIDATE
protected static final short
PSVI
protected static final short
WELLFORMED
protected static final short
NSDECL
protected static final short
INFOSET_TRUE_PARAMS
protected static final short
INFOSET_FALSE_PARAMS
protected static final short
INFOSET_MASK
protected org.apache.xerces.util.SymbolTable
fSymbolTable
Symbol table.
protected ArrayList
fComponents
Components.
protected org.apache.xerces.impl.validation.ValidationManager
fValidationManager
protected Locale
fLocale
Locale.
protected org.apache.xerces.impl.XMLErrorReporter
fErrorReporter
Error reporter
protected final org.apache.xerces.util.DOMErrorHandlerWrapper
fErrorHandlerWrapper
protected org.apache.xerces.impl.dv.DTDDVFactory
fCurrentDVFactory
Current Datatype validator factory.
protected org.apache.xerces.impl.dv.DTDDVFactory
fDatatypeValidatorFactory
The XML 1.0 Datatype validator factory.
protected org.apache.xerces.impl.dv.DTDDVFactory
fXML11DatatypeFactory
The XML 1.1 Datatype validator factory.
private String
fSchemaLocation
private DOMStringList
fRecognizedParameters
Constructors Summary
protected DOMConfigurationImpl()
Default Constructor.


    //
    // Constructors
    //

       
      
        this(null, null);
    
protected DOMConfigurationImpl(org.apache.xerces.util.SymbolTable symbolTable)
Constructs a parser configuration using the specified symbol table.

param
symbolTable The symbol table to use.

        this(symbolTable, null);
    
protected DOMConfigurationImpl(org.apache.xerces.util.SymbolTable symbolTable, org.apache.xerces.xni.parser.XMLComponentManager parentSettings)
Constructs a parser configuration using the specified symbol table and parent settings.

param
symbolTable The symbol table to use.
param
parentSettings The parent settings.

        super(parentSettings);

        // create storage for recognized features and properties
        fRecognizedFeatures = new ArrayList();
        fRecognizedProperties = new ArrayList();

        // create table for features and properties
        fFeatures = new HashMap();
        fProperties = new HashMap();

        // add default recognized features
        final String[] recognizedFeatures = {
            XERCES_VALIDATION,
            XERCES_NAMESPACES,
            SCHEMA,
            SCHEMA_FULL_CHECKING,
            DYNAMIC_VALIDATION,
            NORMALIZE_DATA,
            SCHEMA_ELEMENT_DEFAULT,
            SEND_PSVI,
            GENERATE_SYNTHETIC_ANNOTATIONS,
            VALIDATE_ANNOTATIONS,
            HONOUR_ALL_SCHEMALOCATIONS,
            USE_GRAMMAR_POOL_ONLY,
            DISALLOW_DOCTYPE_DECL_FEATURE,
            BALANCE_SYNTAX_TREES,
            WARN_ON_DUPLICATE_ATTDEF,
            PARSER_SETTINGS
        };
        addRecognizedFeatures(recognizedFeatures);

        // set state for default features
        setFeature(XERCES_VALIDATION, false);
        setFeature(SCHEMA, false);
        setFeature(SCHEMA_FULL_CHECKING, false);
        setFeature(DYNAMIC_VALIDATION, false);
        setFeature(NORMALIZE_DATA, false);
        setFeature(SCHEMA_ELEMENT_DEFAULT, false);
        setFeature(XERCES_NAMESPACES, true);
        setFeature(SEND_PSVI, true);
        setFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false);
        setFeature(VALIDATE_ANNOTATIONS, false);
        setFeature(HONOUR_ALL_SCHEMALOCATIONS, false);
        setFeature(USE_GRAMMAR_POOL_ONLY, false);
        setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, false);
        setFeature(BALANCE_SYNTAX_TREES, false);
        setFeature(WARN_ON_DUPLICATE_ATTDEF, false);
        setFeature(PARSER_SETTINGS, true);

        // add default recognized properties
        final String[] recognizedProperties = {
            XML_STRING,
            SYMBOL_TABLE,
            ERROR_HANDLER,
            ENTITY_RESOLVER,
            ERROR_REPORTER,
            ENTITY_MANAGER,
            VALIDATION_MANAGER,
            GRAMMAR_POOL,
            JAXP_SCHEMA_SOURCE,
            JAXP_SCHEMA_LANGUAGE,
            SCHEMA_LOCATION,
            SCHEMA_NONS_LOCATION,
            DTD_VALIDATOR_PROPERTY,
            DTD_VALIDATOR_FACTORY_PROPERTY
        };
        addRecognizedProperties(recognizedProperties);

        // set default values for normalization features
        features |= NAMESPACES;
        features |= ENTITIES;
        features |= COMMENTS;
        features |= CDATA;
        features |= SPLITCDATA;
        features |= WELLFORMED;
        features |= NSDECL;

        if (symbolTable == null) {
            symbolTable = new SymbolTable();
        }
        fSymbolTable = symbolTable;

        fComponents = new ArrayList();

        setProperty(SYMBOL_TABLE, fSymbolTable);
        fErrorReporter = new XMLErrorReporter();
        setProperty(ERROR_REPORTER, fErrorReporter);
        addComponent(fErrorReporter);

        fDatatypeValidatorFactory = DTDDVFactory.getInstance();
        fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY);
        fCurrentDVFactory = fDatatypeValidatorFactory;
        setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory);
		
        XMLEntityManager manager =  new XMLEntityManager();
        setProperty(ENTITY_MANAGER, manager);
        addComponent(manager);

        fValidationManager = createValidationManager();
        setProperty(VALIDATION_MANAGER, fValidationManager);


        // add message formatters
        if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
            XMLMessageFormatter xmft = new XMLMessageFormatter();
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
        }

        // REVISIT: try to include XML Schema formatter.
        //          This is a hack to allow DTD configuration to be build.
        //
        if (fErrorReporter.getMessageFormatter("http://www.w3.org/TR/xml-schema-1") == null) {
            MessageFormatter xmft = null;
            try {
               xmft = (MessageFormatter)(
                    ObjectFactory.newInstance("org.apache.xerces.impl.xs.XSMessageFormatter",
                    ObjectFactory.findClassLoader(), true));
            } catch (Exception exception){
            }

             if (xmft !=  null) {
                 fErrorReporter.putMessageFormatter("http://www.w3.org/TR/xml-schema-1", xmft);
             }
        }


        // set locale
        try {
            setLocale(Locale.getDefault());
        }
        catch (XNIException e) {
            // do nothing
            // REVISIT: What is the right thing to do? -Ac
        }


    
Methods Summary
protected voidaddComponent(org.apache.xerces.xni.parser.XMLComponent component)


        // don't add a component more than once
        if (fComponents.contains(component)) {
            return;
        }
        fComponents.add(component);

        // register component's recognized features
        String[] recognizedFeatures = component.getRecognizedFeatures();
        addRecognizedFeatures(recognizedFeatures);

        // register component's recognized properties
        String[] recognizedProperties = component.getRecognizedProperties();
        addRecognizedProperties(recognizedProperties);

    
public booleancanSetParameter(java.lang.String name, java.lang.Object value)
DOM Level 3 WD - Experimental. Check if setting a parameter to a specific value is supported.

param
name The name of the parameter to check.
param
value An object. if null, the returned value is true.
return
true if the parameter could be successfully set to the specified value, or false if the parameter is not recognized or the requested value is not supported. This does not change the current value of the parameter itself.


        if (value == null){
            //if null, the returned value is true.
            //REVISIT: I dont like this --- even for unrecognized parameter it would
            //return 'true'. I think it should return false in that case.
            // Application will be surprised to find that setParameter throws not
            //recognized exception when canSetParameter returns 'true' Then what is the use
            //of having canSetParameter ??? - nb.
            return true ;
        }
        if( value instanceof Boolean ){
            //features whose parameter value can be set either 'true' or 'false'
            // or they accept any boolean value -- so we just need to check that
            // its a boolean value..
            if (name.equalsIgnoreCase(Constants.DOM_COMMENTS)
                || name.equalsIgnoreCase(Constants.DOM_DATATYPE_NORMALIZATION)
                || name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)
                || name.equalsIgnoreCase(Constants.DOM_ENTITIES)
                || name.equalsIgnoreCase(Constants.DOM_SPLIT_CDATA)
                || name.equalsIgnoreCase(Constants.DOM_NAMESPACES)
                || name.equalsIgnoreCase(Constants.DOM_VALIDATE)
                || name.equalsIgnoreCase(Constants.DOM_WELLFORMED)
                || name.equalsIgnoreCase(Constants.DOM_INFOSET)
                || name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)
                ) {
                return true;
            }//features whose parameter value can not be set to 'true'
            else if (
                name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
                    || name.equalsIgnoreCase(Constants.DOM_CANONICAL_FORM)
                    || name.equalsIgnoreCase(Constants.DOM_VALIDATE_IF_SCHEMA)
                    || name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION)
                    ) {
                    return (value.equals(Boolean.TRUE)) ? false : true;
            }//features whose parameter value can not be set to 'false'
            else if( name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
                    || name.equalsIgnoreCase(SEND_PSVI)
                    ) {
                    return (value.equals(Boolean.TRUE)) ? true : false;
            }// if name is not among the above listed above -- its not recognized. return false
            else {
                return false ;
            }
        }
		else if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
            return (value instanceof DOMErrorHandler) ? true : false ;
        }
        else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) {
            return (value instanceof LSResourceResolver) ? true : false ;
        }
        else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) {
            return (value instanceof String) ? true : false ;
        }
        else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) {
            // REVISIT: should null value be supported?
            // as of now we are only supporting W3C XML Schema and DTD.
            return ((value instanceof String) && 
                    (value.equals(Constants.NS_XMLSCHEMA) || value.equals(Constants.NS_DTD))) ? true : false;
        }
        else if (name.equalsIgnoreCase(ENTITY_RESOLVER)) {
            return (value instanceof XMLEntityResolver) ? true : false;
        }
        else if (name.equalsIgnoreCase(SYMBOL_TABLE)){
            // Xerces Symbol Table
            return (value instanceof SymbolTable) ? true : false ;
        }
        else if (name.equalsIgnoreCase (GRAMMAR_POOL)){
            return (value instanceof XMLGrammarPool) ? true : false ;
        }
        else {
            //false if the parameter is not recognized or the requested value is not supported.
            return false ;
        }

	
protected voidcheckProperty(java.lang.String propertyId)
Check a property. If the property is known and supported, this method simply returns. Otherwise, the appropriate exception is thrown.

param
propertyId The unique identifier (URI) of the property being set.
exception
org.apache.xerces.xni.parser.XMLConfigurationException If the requested feature is not known or supported.


        // special cases
        if (propertyId.startsWith(Constants.SAX_PROPERTY_PREFIX)) {
            final int suffixLength = propertyId.length() - Constants.SAX_PROPERTY_PREFIX.length();

            //
            // http://xml.org/sax/properties/xml-string
            // Value type: String
            // Access: read-only
            //   Get the literal string of characters associated with the
            //   current event.  If the parser recognises and supports this
            //   property but is not currently parsing text, it should return
            //   null (this is a good way to check for availability before the
            //   parse begins).
            //
            if (suffixLength == Constants.XML_STRING_PROPERTY.length() &&
                propertyId.endsWith(Constants.XML_STRING_PROPERTY)) {
                // REVISIT - we should probably ask xml-dev for a precise
                // definition of what this is actually supposed to return, and
                // in exactly which circumstances.
                short type = XMLConfigurationException.NOT_SUPPORTED;
                throw new XMLConfigurationException(type, propertyId);
            }
        }

        // check property
        super.checkProperty(propertyId);

    
protected org.apache.xerces.impl.validation.ValidationManagercreateValidationManager()

        return new ValidationManager();
    
public org.apache.xerces.xni.XMLDTDContentModelHandlergetDTDContentModelHandler()
Returns the registered DTD content model handler.

        return null;
    
public org.apache.xerces.xni.XMLDTDHandlergetDTDHandler()
Returns the registered DTD handler.

        return null;
    
public org.apache.xerces.xni.XMLDocumentHandlergetDocumentHandler()
Returns the registered document handler.

        return fDocumentHandler;
    
public org.apache.xerces.xni.parser.XMLEntityResolvergetEntityResolver()
Return the current entity resolver.

return
The current entity resolver, or null if none has been registered.
see
#setEntityResolver

        return (XMLEntityResolver)fProperties.get(ENTITY_RESOLVER);
    
public org.apache.xerces.xni.parser.XMLErrorHandlergetErrorHandler()
Return the current error handler.

return
The current error handler, or null if none has been registered.
see
#setErrorHandler

        return (XMLErrorHandler)fProperties.get(ERROR_HANDLER);
    
public booleangetFeature(java.lang.String featureId)
Returns the state of a feature.

param
featureId The feature identifier.
return
true if the feature is supported
throws
XMLConfigurationException Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

        if (featureId.equals(PARSER_SETTINGS)) {
            return true;
        }
        return super.getFeature(featureId);
    
public java.util.LocalegetLocale()
Returns the locale.

        return fLocale;
    
public java.lang.ObjectgetParameter(java.lang.String name)
DOM Level 3 WD - Experimental. getParameter


		// REVISIT: Recognizes DOM L3 default features only.
		//          Does not yet recognize Xerces features.

		if (name.equalsIgnoreCase(Constants.DOM_COMMENTS)) {
			return ((features & COMMENTS) != 0) ? Boolean.TRUE : Boolean.FALSE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACES)) {
			return (features & NAMESPACES) != 0 ? Boolean.TRUE : Boolean.FALSE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_DATATYPE_NORMALIZATION)) {
			// REVISIT: datatype-normalization only takes effect if validation is on
			return (features & DTNORMALIZATION) != 0 ? Boolean.TRUE : Boolean.FALSE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
			return (features & CDATA) != 0 ? Boolean.TRUE : Boolean.FALSE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_ENTITIES)) {
			return (features & ENTITIES) != 0 ? Boolean.TRUE : Boolean.FALSE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_SPLIT_CDATA)) {
			return (features & SPLITCDATA) != 0 ? Boolean.TRUE : Boolean.FALSE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_VALIDATE)) {
			return (features & VALIDATE) != 0 ? Boolean.TRUE : Boolean.FALSE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_WELLFORMED)) {
			return (features & WELLFORMED) != 0 ? Boolean.TRUE : Boolean.FALSE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
		    return (features & NSDECL) != 0 ? Boolean.TRUE : Boolean.FALSE;
		} 
		else if (name.equalsIgnoreCase(Constants.DOM_INFOSET)) {
			return (features & INFOSET_MASK) == INFOSET_TRUE_PARAMS ? Boolean.TRUE : Boolean.FALSE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
				|| name.equalsIgnoreCase(Constants.DOM_CANONICAL_FORM)
				|| name.equalsIgnoreCase(Constants.DOM_VALIDATE_IF_SCHEMA)
				|| name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION)
                ) {
			return Boolean.FALSE;
		}
        else if (name.equalsIgnoreCase(SEND_PSVI)) {
            return Boolean.TRUE;
        }
        else if (name.equalsIgnoreCase(Constants.DOM_PSVI)) {
            return (features & PSVI) != 0 ? Boolean.TRUE : Boolean.FALSE;
        }		
        else if (name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
			return Boolean.TRUE;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
            return fErrorHandlerWrapper.getErrorHandler();
		}
		else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) {
			XMLEntityResolver entityResolver = getEntityResolver();
			if (entityResolver != null && entityResolver instanceof DOMEntityResolverWrapper) {
				return ((DOMEntityResolverWrapper) entityResolver).getEntityResolver();
			}
			return null;
		}
		else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) {
			return getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE);
		}
		else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) {
            return fSchemaLocation;
		}
        else if (name.equalsIgnoreCase(ENTITY_RESOLVER)) {
            return getEntityResolver();
        }
        else if (name.equalsIgnoreCase(SYMBOL_TABLE)){
            return getProperty(SYMBOL_TABLE);
        }
        else if (name.equalsIgnoreCase(GRAMMAR_POOL)){
            return getProperty(GRAMMAR_POOL);
        }
		else {
			String msg =
				DOMMessageFormatter.formatMessage(
					DOMMessageFormatter.DOM_DOMAIN,
					"FEATURE_NOT_FOUND",
					new Object[] { name });
			throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
		}

	
public org.w3c.dom.DOMStringListgetParameterNames()
DOM Level 3 CR - Experimental. The list of the parameters supported by this DOMConfiguration object and for which at least one value can be set by the application. Note that this list can also contain parameter names defined outside this specification.

	    if (fRecognizedParameters == null){
	        Vector parameters = new Vector();

	        //Add DOM recognized parameters
	        //REVISIT: Would have been nice to have a list of
	        //recognized paramters.
	        parameters.add(Constants.DOM_COMMENTS);
	        parameters.add(Constants.DOM_DATATYPE_NORMALIZATION);
	        parameters.add(Constants.DOM_CDATA_SECTIONS);
	        parameters.add(Constants.DOM_ENTITIES);
	        parameters.add(Constants.DOM_SPLIT_CDATA);
	        parameters.add(Constants.DOM_NAMESPACES);
	        parameters.add(Constants.DOM_VALIDATE);

	        parameters.add(Constants.DOM_INFOSET);
	        parameters.add(Constants.DOM_NORMALIZE_CHARACTERS);
	        parameters.add(Constants.DOM_CANONICAL_FORM);
	        parameters.add(Constants.DOM_VALIDATE_IF_SCHEMA);
	        parameters.add(Constants.DOM_CHECK_CHAR_NORMALIZATION);
	        parameters.add(Constants.DOM_WELLFORMED);

	        parameters.add(Constants.DOM_NAMESPACE_DECLARATIONS);
	        parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE);

	        parameters.add(Constants.DOM_ERROR_HANDLER);
	        parameters.add(Constants.DOM_SCHEMA_TYPE);
	        parameters.add(Constants.DOM_SCHEMA_LOCATION);
	        parameters.add(Constants.DOM_RESOURCE_RESOLVER);

	        //Add recognized xerces features and properties
	        parameters.add(ENTITY_RESOLVER);
	        parameters.add(GRAMMAR_POOL);
	        parameters.add(SYMBOL_TABLE);
	        parameters.add(SEND_PSVI);

	        fRecognizedParameters = new DOMStringListImpl(parameters);

	    }

	    return fRecognizedParameters;
	
public voidparse(org.apache.xerces.xni.parser.XMLInputSource inputSource)
Parse an XML document.

The parser can use this method to instruct this configuration to begin parsing an XML document from any valid input source (a character stream, a byte stream, or a URI).

Parsers may not invoke this method while a parse is in progress. Once a parse is complete, the parser may then parse another XML document.

This method is synchronous: it will not return until parsing has ended. If a client application wants to terminate parsing early, it should throw an exception.

param
inputSource The input source for the top-level of the XML document.
exception
XNIException Any XNI exception, possibly wrapping another exception.
exception
IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the parser.

        // no-op
    
protected voidreset()
reset all components before parsing


        if (fValidationManager != null)
            fValidationManager.reset();

        int count = fComponents.size();
        for (int i = 0; i < count; i++) {
            XMLComponent c = (XMLComponent) fComponents.get(i);
            c.reset(this);
        }

    
public voidsetDTDContentModelHandler(org.apache.xerces.xni.XMLDTDContentModelHandler handler)
Sets the DTD content model handler.

param
handler The DTD content model handler.

        //no-op

    
public voidsetDTDHandler(org.apache.xerces.xni.XMLDTDHandler dtdHandler)
Sets the DTD handler.

param
dtdHandler The DTD handler.

        //no-op
    
protected final voidsetDTDValidatorFactory(java.lang.String version)

        if ("1.1".equals(version)) {
            if (fCurrentDVFactory != fXML11DatatypeFactory) {
                fCurrentDVFactory = fXML11DatatypeFactory;
                setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory);
            }
        }
        else if (fCurrentDVFactory != fDatatypeValidatorFactory) {
            fCurrentDVFactory = fDatatypeValidatorFactory;
            setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory);
        }
    
public voidsetDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler documentHandler)
Sets the document handler on the last component in the pipeline to receive information about the document.

param
documentHandler The document handler.

        fDocumentHandler = documentHandler;
    
public voidsetEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver resolver)
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.

        fProperties.put(ENTITY_RESOLVER, resolver);
    
public voidsetErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler 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.

param
errorHandler The error handler.
exception
java.lang.NullPointerException If the handler argument is null.
see
#getErrorHandler

        if (errorHandler != null) {
            fProperties.put(ERROR_HANDLER, errorHandler);
        }
    
public voidsetFeature(java.lang.String featureId, boolean state)
Set the state of a feature. 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
org.apache.xerces.xni.parser.XMLConfigurationException If the requested feature is not known.


        // save state if noone "objects"
        super.setFeature(featureId, state);

    
public voidsetLocale(java.util.Locale locale)
Set the locale to use for messages.

param
locale The locale object to use for localization of messages.
exception
XNIException Thrown if the parser does not support the specified locale.

        fLocale = locale;
        fErrorReporter.setLocale(locale);

    
public voidsetParameter(java.lang.String name, java.lang.Object value)
DOM Level 3 WD - Experimental. setParameter

    	boolean found = true;

        // REVISIT: Recognizes DOM L3 default features only.
        //          Does not yet recognize Xerces features.
		if(value instanceof Boolean){
	   		boolean state = ((Boolean)value).booleanValue();

            if (name.equalsIgnoreCase(Constants.DOM_COMMENTS)) {
                features = (short) (state ? features | COMMENTS : features & ~COMMENTS);
            }
            else if (name.equalsIgnoreCase(Constants.DOM_DATATYPE_NORMALIZATION)) {
                setFeature(NORMALIZE_DATA, state);
                features =
                    (short) (state ? features | DTNORMALIZATION : features & ~DTNORMALIZATION);
                if (state) {
                    features = (short) (features | VALIDATE);
                }
            }
            else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACES)) {
                features = (short) (state ? features | NAMESPACES : features & ~NAMESPACES);
            }
            else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
                features = (short) (state ? features | CDATA : features & ~CDATA);
            }
            else if (name.equalsIgnoreCase(Constants.DOM_ENTITIES)) {
                features = (short) (state ? features | ENTITIES : features & ~ENTITIES);
            }
            else if (name.equalsIgnoreCase(Constants.DOM_SPLIT_CDATA)) {
                features = (short) (state ? features | SPLITCDATA : features & ~SPLITCDATA);
            }
            else if (name.equalsIgnoreCase(Constants.DOM_VALIDATE)) {
                features = (short) (state ? features | VALIDATE : features & ~VALIDATE);
            }
            else if (name.equalsIgnoreCase(Constants.DOM_WELLFORMED)) {
                features = (short) (state ? features | WELLFORMED : features & ~WELLFORMED );
            }
            else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
                features = (short) (state ? features | NSDECL : features & ~NSDECL);
            }
            else if (name.equalsIgnoreCase(Constants.DOM_INFOSET)) {
                // Setting to false has no effect.
                if (state) {
                    features = (short) (features | INFOSET_TRUE_PARAMS);
                    features = (short) (features & ~INFOSET_FALSE_PARAMS);
                    setFeature(NORMALIZE_DATA, false);
                }
            }
            else if (name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
                    || name.equalsIgnoreCase(Constants.DOM_CANONICAL_FORM)
                    || name.equalsIgnoreCase(Constants.DOM_VALIDATE_IF_SCHEMA)
                    || name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION)
                    ) {
                if (state) { // true is not supported
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "FEATURE_NOT_SUPPORTED",
                            new Object[] { name });
                    throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
                }
            }
			else if ( name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
                if (!state) { // false is not supported
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "FEATURE_NOT_SUPPORTED",
                            new Object[] { name });
                   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
                }
            }
            else if (name.equalsIgnoreCase(SEND_PSVI) ){
                // REVISIT: turning augmentation of PSVI is not support,
                // because in this case we won't be able to retrieve element
                // default value.
                if (!state) { // false is not supported
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "FEATURE_NOT_SUPPORTED",
                            new Object[] { name });
                    throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
                }
            }
            else if (name.equalsIgnoreCase(Constants.DOM_PSVI)){
                  features = (short) (state ? features | PSVI : features & ~PSVI);
            }
            else {
            	found = false;
                /*
                String msg =
                    DOMMessageFormatter.formatMessage(
                        DOMMessageFormatter.DOM_DOMAIN,
                        "FEATURE_NOT_FOUND",
                        new Object[] { name });
                throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
                */
            }
            
        }
		
		if (!found || !(value instanceof Boolean))  { // set properties
			found = true;

            if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
                if (value instanceof DOMErrorHandler || value == null) {
                    fErrorHandlerWrapper.setErrorHandler((DOMErrorHandler)value);
                    setErrorHandler(fErrorHandlerWrapper);
                }

                else {
                    // REVISIT: type mismatch
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "TYPE_MISMATCH_ERR",
                            new Object[] { name });
                    throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
                }
            }
            else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) {
                if (value instanceof LSResourceResolver || value == null) {
                    try {
                        setEntityResolver(new DOMEntityResolverWrapper((LSResourceResolver) value));
                    }
                    catch (XMLConfigurationException e) {}
                }
                else {
                    // REVISIT: type mismatch
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "TYPE_MISMATCH_ERR",
                            new Object[] { name });
                    throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
                }

            }
            else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) {
                if (value instanceof String || value == null) {
                    try {
                        if (value == null) {
                            fSchemaLocation = null;
                            setProperty (
                                Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE,
                                null);
                        }
                        else {
                            fSchemaLocation = (String) value;
                            // map DOM schema-location to JAXP schemaSource property
                            // tokenize location string
                            StringTokenizer t = new StringTokenizer(fSchemaLocation, " \n\t\r");
                            if (t.hasMoreTokens()) {
                                ArrayList locations = new ArrayList();
                                locations.add(t.nextToken());
                                while (t.hasMoreTokens()) {
                                    locations.add (t.nextToken());
                                }
                                setProperty (
                                    Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE,
                                    locations.toArray(new String[locations.size()]));
                            }
                            else {
                                setProperty (
                                    Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE,
                                    new String [] {(String) value});
                            }
                        }
                    }
                    catch (XMLConfigurationException e) {}
                }
                else {
                    // REVISIT: type mismatch
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "TYPE_MISMATCH_ERR",
                            new Object[] { name });
                    throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
                }

            }
            else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) {
                if (value instanceof String || value == null) {
                    try {
                        if (value == null) {
                            setProperty(
                                Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
                                null);                  		
                        }
                        else if (value.equals(Constants.NS_XMLSCHEMA)) {
                            // REVISIT: when add support to DTD validation
                            setProperty(
                                Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
                                Constants.NS_XMLSCHEMA);
                        }	                        
                        else if (value.equals(Constants.NS_DTD)) {
                            // Added support for revalidation against DTDs
                        	setProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
                        			Constants.NS_DTD);
                        }
                    }
                    catch (XMLConfigurationException e) {}
                }
                else {
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "TYPE_MISMATCH_ERR",
                            new Object[] { name });
                    throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
                }

            }
            else if (name.equalsIgnoreCase(ENTITY_RESOLVER)) {
                if (value instanceof XMLEntityResolver || value == null) {
                    try {
                        setEntityResolver((XMLEntityResolver) value);
                    }
                    catch (XMLConfigurationException e) {}
                }
                else {
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "TYPE_MISMATCH_ERR",
                            new Object[] { name });
                    throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
                }
            }
            else if (name.equalsIgnoreCase(SYMBOL_TABLE)){
                // Xerces Symbol Table
                if (value instanceof SymbolTable){
                    setProperty(SYMBOL_TABLE, value);
                }
                else {
                    // REVISIT: type mismatch
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "TYPE_MISMATCH_ERR",
                            new Object[] { name });
                    throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
                }
            }
            else if (name.equalsIgnoreCase (GRAMMAR_POOL)){
                if (value instanceof XMLGrammarPool || value == null) {
                    setProperty(GRAMMAR_POOL, value);
                }
                else {
                    // REVISIT: type mismatch
                    String msg =
                        DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "TYPE_MISMATCH_ERR",
                            new Object[] { name });
                    throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
                }

            }
            else {
                // REVISIT: check if this is a boolean parameter -- type mismatch should be thrown.
                //parameter is not recognized
                String msg =
                    DOMMessageFormatter.formatMessage(
                        DOMMessageFormatter.DOM_DOMAIN,
                        "FEATURE_NOT_FOUND",
                        new Object[] { name });
                throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
            }
        }

    
public voidsetProperty(java.lang.String propertyId, java.lang.Object value)
setProperty

param
propertyId
param
value


        // store value if noone "objects"
        super.setProperty(propertyId, value);