/*
* 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 implementation specific class for the
* <code>javax.xml.parsers.SAXParser</code>.
*
* @author Rajiv Mordani
* @author Edwin Goei
*
* @version $Id: SAXParserImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $
*/
implements JAXPConstants, PSVIProvider {
/** Feature identifier: namespaces. */
/** Feature identifier: namespace prefixes. */
/** Feature identifier: validation. */
/** Feature identifier: XML Schema validation */
/** Feature identifier: XInclude processing */
/** Property identifier: security manager. */
/** property identifier: access external dtd. */
/** Property identifier: access to external schema */
/** Initial ErrorHandler */
/** Initial EntityResolver */
/**
* Create a SAX parser with the associated features
* @param features Hashtable of SAX features, may be null
*/
throws SAXException {
}
/**
* Create a SAX parser with the associated features
* @param features Hashtable of SAX features, may be null
*/
throws SAXException
{
// Instantiate a SAXParser directly and not through SAX so that we use the right ClassLoader
xmlReader = new JAXPSAXParser(this);
// JAXP "namespaceAware" == SAX Namespaces feature
// Note: there is a compatibility problem here with default values:
// JAXP default is false while SAX 2 default is true!
// SAX "namespaces" and "namespace-prefixes" features should not
// both be false. We make them opposite for backward compatibility
// since JAXP 1.0 apps may want to receive xmlns* attributes.
// Avoid setting the XInclude processing feature if the value is false.
// This will keep the configuration from throwing an exception if it
// does not support XInclude.
if (spf.isXIncludeAware()) {
}
// If the secure processing feature is on set a security manager.
if (secureProcessing) {
/**
* By default, secure processing is set, no external access is allowed.
* However, we need to check if it is actively set on the factory since we
* allow the use of the System Property or jaxp.properties to override
* the default value
*/
if (value) {
}
}
}
}
// Set application's features, followed by validation features.
// If validating, provide a default ErrorHandler that prints
// validation errors with a warning telling the user to set an
// ErrorHandler.
if (spf.isValidating()) {
}
else {
}
// Get the Schema object from the factory
/** For Xerces grammars, use built-in schema validator. **/
if (grammar instanceof XSGrammarPoolContainer) {
validatorComponent = new XMLSchemaValidator();
}
/** For third party grammars, use the JAXP validator component. **/
else {
}
}
else {
}
// Initial EntityResolver
}
/**
* Set any features of our XMLReader based on any features set on the
* SAXParserFactory.
*
* XXX Does not handle possible conflicts between SAX feature names and
* JAXP specific feature names, eg. SAXParserFactory.isValidating()
*/
}
}
}
// Xerces2 AbstractSAXParser implements SAX1 Parser
// assert(xmlReader instanceof Parser);
}
/**
* Returns the XMLReader that is encapsulated by the implementation of
* this class.
*/
return xmlReader;
}
public boolean isNamespaceAware() {
try {
}
catch (SAXException x) {
throw new IllegalStateException(x.getMessage());
}
}
public boolean isValidating() {
try {
}
catch (SAXException x) {
throw new IllegalStateException(x.getMessage());
}
}
/**
* Gets the XInclude processing mode for this parser
* @return the state of XInclude processing mode
*/
public boolean isXIncludeAware() {
try {
}
catch (SAXException exc) {
return false;
}
}
/**
* Sets the particular property in the underlying implementation of
* org.xml.sax.XMLReader.
*/
}
/**
* returns the particular property requested for in the underlying
* implementation of org.xml.sax.XMLReader.
*/
}
throws SAXException, IOException {
throw new IllegalArgumentException();
}
}
}
throws SAXException, IOException {
throw new IllegalArgumentException();
}
}
}
return grammar;
}
public void reset() {
try {
/** Restore initial values of features and properties. **/
}
catch (SAXException exc) {
// This should never happen. We only store recognized
// features and properties in the hash maps. For now
// just ignore it.
}
/** Restore various handlers. **/
}
}
}
/*
* PSVIProvider methods
*/
}
}
}
/**
* Extension of SAXParser. This class tracks changes to
* features and properties to allow the parser to be reset to
* its initial state.
*/
public JAXPSAXParser() {
this(null);
}
super();
}
/**
* Override SAXParser's setFeature method to track the initial state
* of features. This keeps us from affecting the performance of the
* SAXParser when it is created with XMLReaderFactory.
*/
// TODO: Add localized error message.
throw new NullPointerException();
}
try {
}
catch (SAXNotRecognizedException exc) {
// If the property is not supported
// re-throw the exception if the value is true.
if (value) {
throw exc;
}
}
catch (SAXNotSupportedException exc) {
// If the property is not supported
// re-throw the exception if the value is true.
if (value) {
throw exc;
}
}
return;
}
}
/** Forward feature to the schema validator if there is one. **/
}
}
// TODO: Add localized error message.
throw new NullPointerException();
}
try {
}
// If the property is not supported the value must be false.
catch (SAXException exc) {
return false;
}
}
return super.getFeature(name);
}
/**
* Override SAXParser's setProperty method to track the initial state
* of properties. This keeps us from affecting the performance of the
* SAXParser when it is created with XMLReaderFactory.
*/
// TODO: Add localized error message.
throw new NullPointerException();
}
if (fSAXParser != null) {
// JAXP 1.2 support
// The spec says if a schema is given via SAXParserFactory
// the JAXP 1.2 properties shouldn't be allowed.
throw new SAXNotSupportedException(
SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), "schema-already-specified", new Object[] {name}));
}
//None of the properties will take effect till the setValidating(true) has been called
if( fSAXParser.isValidating() ) {
// this will allow the parser not to emit DTD-related
// errors, as the spec demands
}
}
}
setFeature(XMLSCHEMA_VALIDATION_FEATURE, false);
}
else {
// REVISIT: It would be nice if we could format this message
// using a user specified locale as we do in the underlying
// XMLReader -- mrglavas
throw new SAXNotSupportedException(
}
return;
}
// The spec says if a schema is given via SAXParserFactory
// the JAXP 1.2 properties shouldn't be allowed.
throw new SAXNotSupportedException(
SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), "schema-already-specified", new Object[] {name}));
}
}
}
else {
throw new SAXNotSupportedException(
"jaxp-order-not-supported",
}
return;
}
}
}
/** Forward property to the schema validator if there is one. **/
}
}
// TODO: Add localized error message.
throw new NullPointerException();
}
// JAXP 1.2 support
return fSAXParser.schemaLanguage;
}
return super.getProperty(name);
}
synchronized void restoreInitState()
if (!fInitFeatures.isEmpty()) {
}
}
if (!fInitProperties.isEmpty()) {
}
}
}
throws SAXException, IOException {
}
}
super.parse(inputSource);
}
throws SAXException, IOException {
}
}
}
return fConfiguration;
}
}
return super.getFeature(name);
}
}
return super.getProperty(name);
}
try {
}
// This should never be thrown from the schema validator.
catch (XMLConfigurationException e) {
throw new SAXNotRecognizedException(
}
else {
throw new SAXNotSupportedException(
}
}
}
try {
}
// This should never be thrown from the schema validator.
catch (XMLConfigurationException e) {
throw new SAXNotRecognizedException(
}
else {
throw new SAXNotSupportedException(
}
}
}
try {
}
// This should never be thrown from the schema validator.
catch (XMLConfigurationException e) {
throw new SAXException(e);
}
}
}
}