This
class
is a factory for SAXParser objects. Obtain a
SAXParserFactory by calling the
newInstance( ) method which instantiates the
default SAXParserFactory subclass provided with
your Java implementation, or instantiates some other
SAXParserFactory that has been
"plugged in".
Once you have a SAXParserFactory object, you can
use setValidating( ) and
setNamespaceAware( ) to specify whether the
parsers it creates will be validating parsers or not and whether they
will know how to handle XML namespaces. You may also call
setFeature( )
to set a feature of the underlying parser implementation. See
http://www.saxproject.org for the
names of standard parser features that can be enabled and disabled
with this method. In Java 5.0, call setXIncludeAware(
) to specify that created parsers will
recognize XInclude markup. Use setSchema(
)
to specify a W3C XML Schema against
which parsers should validate the document.
Once you have created and configured your factory object, simply call
newSAXParser( ) to create a SAXParser
object. Note that SAXParserFactory implementations
are not typically threadsafe.
The javax.xml.parsers package allows parser
implementations to be "plugged in".
This pluggability is provided by the getInstance(
) method, which follows the following steps to determine
which SAXBuilderFactory subclass to use:
If the javax.xml.parsers.SAXParserFactory system
property is defined, then the class specified by that property is
used.
Otherwise, if the
jre/lib/jaxp.properties file
exists in the Java distribution and contains a definition for the
javax.xml.parsers.SAXParserFactory property, then
the class specified by that property is used.
Otherwise, if any of the JAR files on the classpath includes a file
named
META-INF/services/javax.xml.parsers.SAXParserFactory ,
then the class named in that file will be used.
Otherwise, a default implementation provided by the Java platform
will be used.
public abstract class SAXParserFactory {
// Protected Constructors
protected
SAXParserFactory ( );
// Public Class Methods
public static SAXParserFactory
newInstance ( );
// Public Instance Methods
public abstract boolean
getFeature (String
name )
throws ParserConfigurationException,
org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException;
5.0 public javax.xml.validation.Schema
getSchema ( );
public boolean
isNamespaceAware ( );
public boolean
isValidating ( );
5.0 public boolean
isXIncludeAware ( );
public abstract SAXParser
newSAXParser ( )
throws ParserConfigurationException,
org.xml.sax.SAXException;
public abstract void
setFeature (String
name , boolean
value )
throws ParserConfigurationException,
org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException;
public void
setNamespaceAware (boolean
awareness );
5.0 public void
setSchema (javax.xml.validation.Schema
schema );
public void
setValidating (boolean
validating );
5.0 public void
setXIncludeAware (boolean
state );
}