Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Protected Ctors](https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#proctors) \| [Methods](https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#inhmethods)

# SAXParserFactory


`
public


abstract
class
SAXParserFactory
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.xml.parsers.SAXParserFactory |

<br />

*** ** * ** ***

Defines a factory API that enables applications to configure and
obtain a SAX based parser to parse XML documents.

## Summary

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#SAXParserFactory()() ` <br /> Protected constructor to force use of `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#newInstance()`. |

| ### Public methods ||
|---|---|
| ` abstract boolean` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#getFeature(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` <br /> Returns the particular property requested for in the underlying implementation of org.xml.sax.XMLReader. |
| ` https://developer.android.com/reference/javax/xml/validation/Schema` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#getSchema()() ` Gets the `https://developer.android.com/reference/javax/xml/validation/Schema` object specified through the `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setSchema(javax.xml.validation.Schema)` method. |
| ` boolean` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#isNamespaceAware()() ` Indicates whether or not the factory is configured to produce parsers which are namespace aware. |
| ` boolean` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#isValidating()() ` Indicates whether or not the factory is configured to produce parsers which validate the XML content during parse. |
| ` boolean` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#isXIncludeAware()() ` <br /> Get state of XInclude processing. |
| ` static https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#newInstance(java.lang.String,%20java.lang.ClassLoader)(https://developer.android.com/reference/java/lang/String factoryClassName, https://developer.android.com/reference/java/lang/ClassLoader classLoader) ` Returns an instance of the named implementation of `SAXParserFactory`. |
| ` static https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#newInstance()() ` Returns Android's implementation of `SAXParserFactory`. |
| ` abstract https://developer.android.com/reference/javax/xml/parsers/SAXParser` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#newSAXParser()() ` <br /> Creates a new instance of a SAXParser using the currently configured factory parameters. |
| ` abstract void` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setFeature(java.lang.String,%20boolean)(https://developer.android.com/reference/java/lang/String name, boolean value) ` <br /> Sets the particular feature in the underlying implementation of org.xml.sax.XMLReader. |
| ` void` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setNamespaceAware(boolean)(boolean awareness) ` Specifies that the parser produced by this code will provide support for XML namespaces. |
| ` void` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setSchema(javax.xml.validation.Schema)(https://developer.android.com/reference/javax/xml/validation/Schema schema) ` <br /> Set the `https://developer.android.com/reference/javax/xml/validation/Schema` to be used by parsers created from this factory. |
| ` void` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setValidating(boolean)(boolean validating) ` Specifies that the parser produced by this code will validate documents as they are parsed. |
| ` void` | ` https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setXIncludeAware(boolean)(boolean state) ` <br /> Set state of XInclude processing. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Protected constructors

### SAXParserFactory

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected SAXParserFactory ()
```

<br />

Protected constructor to force use of `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#newInstance()`.

<br />

<br />

## Public methods

### getFeature

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean getFeature (String name)
```

<br />

Returns the particular property requested for in the underlying
implementation of org.xml.sax.XMLReader.

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String`: The name of the property to be retrieved. <br /> |

| Returns ||
|---|---|
| `boolean` | Value of the requested property. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/xml/parsers/ParserConfigurationException` | if a parser cannot be created which satisfies the requested configuration. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotRecognizedException` | When the underlying XMLReader does not recognize the property name. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotSupportedException` | When the underlying XMLReader recognizes the property name but doesn't support the property. |

**See also:**

- `https://developer.android.com/reference/org/xml/sax/XMLReader#getProperty(java.lang.String)`

### getSchema

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Schema getSchema ()
```

Gets the `https://developer.android.com/reference/javax/xml/validation/Schema` object specified through
the `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setSchema(javax.xml.validation.Schema)` method.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/validation/Schema` | the `https://developer.android.com/reference/javax/xml/validation/Schema` object that was last set through the `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setSchema(javax.xml.validation.Schema)` method, or null if the method was not invoked since a `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory` is created. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |

### isNamespaceAware

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isNamespaceAware ()
```

Indicates whether or not the factory is configured to produce
parsers which are namespace aware.

<br />

| Returns ||
|---|---|
| `boolean` | true if the factory is configured to produce parsers which are namespace aware; false otherwise. <br /> |

### isValidating

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isValidating ()
```

Indicates whether or not the factory is configured to produce
parsers which validate the XML content during parse.

<br />

| Returns ||
|---|---|
| `boolean` | true if the factory is configured to produce parsers which validate the XML content during parse; false otherwise. <br /> |

### isXIncludeAware

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isXIncludeAware ()
```

<br />

Get state of XInclude processing.

<br />

<br />

| Returns ||
|---|---|
| `boolean` | current state of XInclude processing <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |

### newInstance

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static SAXParserFactory newInstance (String factoryClassName, 
                ClassLoader classLoader)
```

Returns an instance of the named implementation of `SAXParserFactory`.

<br />

| Parameters ||
|---|---|
| `factoryClassName` | `String` <br /> |
| `classLoader` | `ClassLoader` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/xml/parsers/FactoryConfigurationError` | if `factoryClassName` is not available or cannot be instantiated. |

### newInstance

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static SAXParserFactory newInstance ()
```

Returns Android's implementation of `SAXParserFactory`. Unlike
other Java implementations, this method does not consult system
properties, property files, or the services API.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory` | a new SAXParserFactory. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/xml/parsers/FactoryConfigurationError` | never. Included for API compatibility with other Java implementations. |

### newSAXParser

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract SAXParser newSAXParser ()
```

<br />

Creates a new instance of a SAXParser using the currently
configured factory parameters.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/parsers/SAXParser` | A new instance of a SAXParser. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/xml/parsers/ParserConfigurationException` | if a parser cannot be created which satisfies the requested configuration. |
| `https://developer.android.com/reference/org/xml/sax/SAXException` | for SAX errors. |

### setFeature

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setFeature (String name, 
                boolean value)
```

<br />

Sets the particular feature in the underlying implementation of
org.xml.sax.XMLReader.
A list of the core features and properties can be found at
<http://www.saxproject.org/>

All implementations are required to support the `https://developer.android.com/reference/javax/xml/XMLConstants#FEATURE_SECURE_PROCESSING` feature.
When the feature is

- `true`: 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 `https://developer.android.com/reference/org/xml/sax/ErrorHandler#fatalError(org.xml.sax.SAXParseException)`. See `https://developer.android.com/reference/javax/xml/parsers/SAXParser` `parse` methods for handler specification.
- When the feature is `false`, the implementation will processing XML according to the XML specifications without regard to possible implementation limits.

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String`: The name of the feature to be set. <br /> |
| `value` | `boolean`: The value of the feature to be set. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If the `name` parameter is null. |
| `https://developer.android.com/reference/javax/xml/parsers/ParserConfigurationException` | if a parser cannot be created which satisfies the requested configuration. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotRecognizedException` | When the underlying XMLReader does not recognize the property name. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotSupportedException` | When the underlying XMLReader recognizes the property name but doesn't support the property. |

**See also:**

- `https://developer.android.com/reference/org/xml/sax/XMLReader#setFeature(java.lang.String,%20boolean)`

### setNamespaceAware

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setNamespaceAware (boolean awareness)
```

Specifies that the parser produced by this code will
provide support for XML namespaces. By default the value of this is set
to `false`.

<br />

| Parameters ||
|---|---|
| `awareness` | `boolean`: true if the parser produced by this code will provide support for XML namespaces; false otherwise. <br /> |

### setSchema

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setSchema (Schema schema)
```

<br />

Set the `https://developer.android.com/reference/javax/xml/validation/Schema` to be used by parsers created
from this factory.

When a `https://developer.android.com/reference/javax/xml/validation/Schema` is non-null, a parser will use a validator
created from it to validate documents before it passes information
down to the application.

When warnings/errors/fatal errors are found by the validator, the parser must
handle them as if those errors were found by the parser itself.
In other words, if the user-specified `https://developer.android.com/reference/org/xml/sax/ErrorHandler`
is set, it must receive those errors, and if not, they must be
treated according to the implementation specific
default error handling rules.

A validator may modify the SAX event stream (for example by
adding default values that were missing in documents), and a parser
is responsible to make sure that the application will receive
those modified event stream.

Initially, `null` is set as the `https://developer.android.com/reference/javax/xml/validation/Schema`.

This processing will take effect even if
the `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#isValidating()` method returns `false`.

It is an error to use
the `http://java.sun.com/xml/jaxp/properties/schemaSource`
property and/or the `http://java.sun.com/xml/jaxp/properties/schemaLanguage`
property in conjunction with a non-null `https://developer.android.com/reference/javax/xml/validation/Schema` object.
Such configuration will cause a `https://developer.android.com/reference/org/xml/sax/SAXException`
exception when those properties are set on a `https://developer.android.com/reference/javax/xml/parsers/SAXParser`.

#### Note for implementors


A parser must be able to work with any `https://developer.android.com/reference/javax/xml/validation/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.

<br />

<br />

| Parameters ||
|---|---|
| `schema` | `Schema`: `Schema` to use, `null` to remove a schema. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |

### setValidating

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setValidating (boolean validating)
```

Specifies that the parser produced by this code will
validate documents as they are parsed. By default the value of this is
set to `false`.


Note that "the validation" here means
[a validating
parser](http://www.w3.org/TR/REC-xml#proc-types) as defined in the XML recommendation.
In other words, it essentially just controls the DTD validation.
(except the legacy two properties defined in JAXP 1.2.
See [here](https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#validationCompatibility) for more details.)


To use modern schema languages such as W3C XML Schema or
RELAX NG instead of DTD, you can configure your parser to be
a non-validating parser by leaving the `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setValidating(boolean)`
method false, then use the `https://developer.android.com/reference/javax/xml/parsers/SAXParserFactory#setSchema(javax.xml.validation.Schema)`
method to associate a schema to a parser.

<br />

<br />

| Parameters ||
|---|---|
| `validating` | `boolean`: true if the parser produced by this code will validate documents as they are parsed; false otherwise. <br /> |

### setXIncludeAware

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setXIncludeAware (boolean state)
```

<br />

Set state of XInclude processing.

If XInclude markup is found in the document instance, should it be
processed as specified in [XML Inclusions (XInclude) Version 1.0](http://www.w3.org/TR/xinclude/).

XInclude processing defaults to `false`.

<br />

<br />

| Parameters ||
|---|---|
| `state` | `boolean`: Set XInclude processing to `true` or `false` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |