src/javax/xml/parsers/SAXParserFactory.java
Print this page
*** 24,34 ****
*/
package javax.xml.parsers;
import javax.xml.validation.Schema;
-
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
/**
--- 24,33 ----
*** 40,51 ****
*
* @version $Revision: 1.9 $, $Date: 2010/05/25 16:19:44 $
*
*/
public abstract class SAXParserFactory {
- /** The default property name according to the JAXP spec */
- private static final String DEFAULT_PROPERTY_NAME = "javax.xml.parsers.SAXParserFactory";
/**
* <p>Should Parsers be validating?</p>
*/
private boolean validating = false;
--- 39,48 ----
*** 85,102 ****
* when the first attempt is made to read from it, no further attempts are
* made to check for its existence. It is not possible to change the value
* of any property in jaxp.properties after it has been read for the first time.
* </li>
* <li>
! * Use the Services API (as detailed in the JAR specification), if
! * available, to determine the classname. The Services API will look
! * for a classname in the file
! * <code>META-INF/services/javax.xml.parsers.SAXParserFactory</code>
! * in jars available to the runtime.
* </li>
* <li>
! * Platform default <code>SAXParserFactory</code> instance.
* </li>
* </ul>
*
* Once an application has obtained a reference to a
* <code>SAXParserFactory</code> it can use the factory to
--- 82,97 ----
* when the first attempt is made to read from it, no further attempts are
* made to check for its existence. It is not possible to change the value
* of any property in jaxp.properties after it has been read for the first time.
* </li>
* <li>
! * Use the service-provider loading facilities, defined by the
! * {@link java.util.ServiceLoader} class, to attempt to locate and load an
! * implementation of the service.
* </li>
* <li>
! * Otherwise the system-default implementation is returned.
* </li>
* </ul>
*
* Once an application has obtained a reference to a
* <code>SAXParserFactory</code> it can use the factory to
*** 107,139 ****
* <h2>Tip for Trouble-shooting</h2>
* <p>Setting the <code>jaxp.debug</code> system property will cause
* this method to print a lot of debug messages
* to <code>System.err</code> about what it is doing and where it is looking at.</p>
*
! * <p> If you have problems loading {@link DocumentBuilder}s, try:</p>
* <pre>
* java -Djaxp.debug=1 YourProgram ....
* </pre>
*
*
* @return A new instance of a SAXParserFactory.
*
! * @throws FactoryConfigurationError if the implementation is
! * not available or cannot be instantiated.
*/
public static SAXParserFactory newInstance() {
! try {
! return (SAXParserFactory) FactoryFinder.find(
/* The default property name according to the JAXP spec */
! "javax.xml.parsers.SAXParserFactory",
/* The fallback implementation class name */
"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
- } catch (FactoryFinder.ConfigurationError e) {
- throw new FactoryConfigurationError(e.getException(),
- e.getMessage());
- }
}
/**
* <p>Obtain a new instance of a <code>SAXParserFactory</code> from class name.
* This function is useful when there are multiple providers in the classpath.
--- 102,130 ----
* <h2>Tip for Trouble-shooting</h2>
* <p>Setting the <code>jaxp.debug</code> system property will cause
* this method to print a lot of debug messages
* to <code>System.err</code> about what it is doing and where it is looking at.</p>
*
! * <p> If you have problems loading {@link SAXParser}s, try:</p>
* <pre>
* java -Djaxp.debug=1 YourProgram ....
* </pre>
*
*
* @return A new instance of a SAXParserFactory.
*
! * @throws FactoryConfigurationError in case of {@linkplain
! * java.util.ServiceConfigurationError service configuration error} or if
! * the implementation is not available or cannot be instantiated.
*/
public static SAXParserFactory newInstance() {
! return FactoryFinder.find(
/* The default property name according to the JAXP spec */
! SAXParserFactory.class,
/* The fallback implementation class name */
"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
}
/**
* <p>Obtain a new instance of a <code>SAXParserFactory</code> from class name.
* This function is useful when there are multiple providers in the classpath.
*** 167,183 ****
* @see #newInstance()
*
* @since 1.6
*/
public static SAXParserFactory newInstance(String factoryClassName, ClassLoader classLoader){
- try {
//do not fallback if given classloader can't find the class, throw exception
! return (SAXParserFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false);
! } catch (FactoryFinder.ConfigurationError e) {
! throw new FactoryConfigurationError(e.getException(),
! e.getMessage());
! }
}
/**
* <p>Creates a new instance of a SAXParser using the currently
* configured factory parameters.</p>
--- 158,170 ----
* @see #newInstance()
*
* @since 1.6
*/
public static SAXParserFactory newInstance(String factoryClassName, ClassLoader classLoader){
//do not fallback if given classloader can't find the class, throw exception
! return FactoryFinder.newInstance(SAXParserFactory.class,
! factoryClassName, classLoader, false);
}
/**
* <p>Creates a new instance of a SAXParser using the currently
* configured factory parameters.</p>
*** 269,279 ****
* <p>All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
* When the feature is</p>
* <ul>
* <li>
* <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
! * Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
* If XML processing is limited for security reasons, it will be reported via a call to the registered
* {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
* See {@link SAXParser} <code>parse</code> methods for handler specification.
* </li>
* <li>
--- 256,266 ----
* <p>All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
* When the feature is</p>
* <ul>
* <li>
* <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
! * Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
* If XML processing is limited for security reasons, it will be reported via a call to the registered
* {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
* See {@link SAXParser} <code>parse</code> methods for handler specification.
* </li>
* <li>
*** 318,338 ****
public abstract boolean getFeature(String name)
throws ParserConfigurationException, SAXNotRecognizedException,
SAXNotSupportedException;
-
- /* <p>Get current state of canonicalization.</p>
- *
- * @return current state canonicalization control
- */
- /*
- public boolean getCanonicalization() {
- return canonicalState;
- }
- */
-
/**
* Gets the {@link Schema} object specified through
* the {@link #setSchema(Schema schema)} method.
*
*
--- 305,314 ----
*** 355,375 ****
+ this.getClass().getPackage().getSpecificationVersion()
+ "\""
);
}
- /** <p>Set canonicalization control to <code>true</code> or
- * </code>false</code>.</p>
- *
- * @param state of canonicalization
- */
- /*
- public void setCanonicalization(boolean state) {
- canonicalState = state;
- }
- */
-
/**
* <p>Set the {@link Schema} to be used by parsers created
* from this factory.</p>
*
* <p>When a {@link Schema} is non-null, a parser will use a validator
--- 331,340 ----
*** 398,408 ****
* property and/or the <code>http://java.sun.com/xml/jaxp/properties/schemaLanguage</code>
* property in conjunction with a non-null {@link Schema} object.
* Such configuration will cause a {@link SAXException}
* exception when those properties are set on a {@link SAXParser}.</p>
*
! * <h4>Note for implmentors</h4>
* <p>
* A parser must be able to work with any {@link Schema}
* implementation. However, parsers and schemas are allowed
* to use implementation-specific custom mechanisms
* as long as they yield the result described in the specification.
--- 363,373 ----
* property and/or the <code>http://java.sun.com/xml/jaxp/properties/schemaLanguage</code>
* property in conjunction with a non-null {@link Schema} object.
* Such configuration will cause a {@link SAXException}
* exception when those properties are set on a {@link SAXParser}.</p>
*
! * <h4>Note for implementors</h4>
* <p>
* A parser must be able to work with any {@link Schema}
* implementation. However, parsers and schemas are allowed
* to use implementation-specific custom mechanisms
* as long as they yield the result described in the specification.