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

# SchemaFactory


`
public


abstract
class
SchemaFactory
`


`

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


`

`


`

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

<br />

*** ** * ** ***

Factory that creates `https://developer.android.com/reference/javax/xml/validation/Schema` objects. Entry-point to
the validation API.


`https://developer.android.com/reference/javax/xml/validation/SchemaFactory` is a schema compiler. It reads external
representations of schemas and prepares them for validation.


The `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` class is not thread-safe. In other words,
it is the application's responsibility to ensure that at most
one thread is using a `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` object at any
given moment. Implementations are encouraged to mark methods
as synchronized to protect themselves from broken clients.


`https://developer.android.com/reference/javax/xml/validation/SchemaFactory` is not re-entrant. While one of the
`newSchema` methods is being invoked, applications
may not attempt to recursively invoke the `newSchema` method,
even from the same thread.

## Schema Language


This spec uses a namespace URI to designate a schema language.
The following table shows the values defined by this specification.


To be compliant with the spec, the implementation
is only required to support W3C XML Schema 1.0. However,
if it chooses to support other schema languages listed here,
it must conform to the relevant behaviors described in this spec.


Schema languages not listed here are expected to
introduce their own URIs to represent themselves.
The `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` class is capable of locating other
implementations for other schema languages at run-time.


Note that because the XML DTD is strongly tied to the parsing process
and has a significant effect on the parsing process, it is impossible
to define the DTD validation as a process independent from parsing.
For this reason, this specification does not define the semantics for
the XML DTD. This doesn't prohibit implementers from implementing it
in a way they see fit, but *users are warned that any DTD
validation implemented on this interface necessarily deviate from
the XML DTD semantics as defined in the XML 1.0*.

| value | language |
|---|---|
| `https://developer.android.com/reference/javax/xml/XMLConstants#W3C_XML_SCHEMA_NS_URI` ("`http://www.w3.org/2001/XMLSchema`") | [W3C XML Schema 1.0](http://www.w3.org/TR/xmlschema-1) |
| `https://developer.android.com/reference/javax/xml/XMLConstants#RELAXNG_NS_URI` ("`http://relaxng.org/ns/structure/1.0`") | [RELAX NG 1.0](http://www.relaxng.org/) |

<br />

## Summary

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#SchemaFactory()() ` <br /> Constructor for derived classes. |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/org/xml/sax/ErrorHandler` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#getErrorHandler()() ` Gets the current `https://developer.android.com/reference/org/xml/sax/ErrorHandler` set to this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory`. |
| ` boolean` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#getFeature(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` Look up the value of a feature flag. |
| ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#getProperty(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` Look up the value of a property. |
| ` abstract https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#getResourceResolver()() ` Gets the current `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver` set to this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory`. |
| ` abstract boolean` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#isSchemaLanguageSupported(java.lang.String)(https://developer.android.com/reference/java/lang/String schemaLanguage) ` <br /> Is specified schema supported by this `SchemaFactory`? <br /> |
| ` static https://developer.android.com/reference/javax/xml/validation/SchemaFactory` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newInstance(java.lang.String,%20java.lang.String,%20java.lang.ClassLoader)(https://developer.android.com/reference/java/lang/String schemaLanguage, 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 `SchemaFactory`. |
| ` static https://developer.android.com/reference/javax/xml/validation/SchemaFactory` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newInstance(java.lang.String)(https://developer.android.com/reference/java/lang/String schemaLanguage) ` <br /> Lookup an implementation of the `SchemaFactory` that supports the specified schema language and return it. |
| ` https://developer.android.com/reference/javax/xml/validation/Schema` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newSchema(java.io.File)(https://developer.android.com/reference/java/io/File schema) ` <br /> Parses the specified `File` as a schema and returns it as a `Schema`. |
| ` https://developer.android.com/reference/javax/xml/validation/Schema` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newSchema(javax.xml.transform.Source)(https://developer.android.com/reference/javax/xml/transform/Source schema) ` <br /> Parses the specified source as a schema and returns it as a schema. |
| ` abstract https://developer.android.com/reference/javax/xml/validation/Schema` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newSchema()() ` Creates a special `https://developer.android.com/reference/javax/xml/validation/Schema` object. |
| ` abstract https://developer.android.com/reference/javax/xml/validation/Schema` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newSchema(javax.xml.transform.Source[])(https://developer.android.com/reference/javax/xml/transform/Source schemas) ` Parses the specified source(s) as a schema and returns it as a schema. |
| ` https://developer.android.com/reference/javax/xml/validation/Schema` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newSchema(java.net.URL)(https://developer.android.com/reference/java/net/URL schema) ` <br /> Parses the specified `URL` as a schema and returns it as a `Schema`. |
| ` abstract void` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setErrorHandler(org.xml.sax.ErrorHandler)(https://developer.android.com/reference/org/xml/sax/ErrorHandler errorHandler) ` Sets the `https://developer.android.com/reference/org/xml/sax/ErrorHandler` to receive errors encountered during the `newSchema` method invocation. |
| ` void` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setFeature(java.lang.String,%20boolean)(https://developer.android.com/reference/java/lang/String name, boolean value) ` Set the value of a feature flag. |
| ` void` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setProperty(java.lang.String,%20java.lang.Object)(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/lang/Object object) ` Set the value of a property. |
| ` abstract void` | ` https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setResourceResolver(org.w3c.dom.ls.LSResourceResolver)(https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver resourceResolver) ` Sets the `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver` to customize resource resolution when parsing schemas. |

| ### 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

### SchemaFactory

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

```
protected SchemaFactory ()
```

<br />

Constructor for derived classes.

The constructor does nothing.

Derived classes must create `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` objects that have
`null` `https://developer.android.com/reference/org/xml/sax/ErrorHandler` and
`null` `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver`.

<br />

<br />

## Public methods

### getErrorHandler

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

```
public abstract ErrorHandler getErrorHandler ()
```

Gets the current `https://developer.android.com/reference/org/xml/sax/ErrorHandler` set to this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/org/xml/sax/ErrorHandler` | This method returns the object that was last set through the `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setErrorHandler(org.xml.sax.ErrorHandler)` method, or null if that method has never been called since this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` has created. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setErrorHandler(org.xml.sax.ErrorHandler)`

### getFeature

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

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

Look up the value of a feature flag.

The feature name is any fully-qualified URI. It is
possible for a `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` to recognize a feature name but
temporarily be unable to return its value.

Implementers are free (and encouraged) to invent their own features,
using names built on their own URIs.

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String`: The feature name, which is a non-null fully-qualified URI. <br /> |

| Returns ||
|---|---|
| `boolean` | The current value of the feature (true or false). <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the name parameter is null. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotRecognizedException` | If the feature value can't be assigned or retrieved. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotSupportedException` | When the `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` recognizes the feature name but cannot determine its value at this time. |

**See also:**

- `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setFeature(java.lang.String,%20boolean)`

### getProperty

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

```
public Object getProperty (String name)
```

Look up the value of a property.

The property name is any fully-qualified URI. It is
possible for a `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` to recognize a property name but
temporarily be unable to return its value.

`https://developer.android.com/reference/javax/xml/validation/SchemaFactory`s are not required to recognize any specific
property names.

Implementers are free (and encouraged) to invent their own properties,
using names built on their own URIs.

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String`: The property name, which is a non-null fully-qualified URI. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Object` | The current value of the property. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the name parameter is null. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotRecognizedException` | If the property value can't be assigned or retrieved. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotSupportedException` | When the XMLReader recognizes the property name but cannot determine its value at this time. |

**See also:**

- `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setProperty(java.lang.String,%20java.lang.Object)`

### getResourceResolver

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

```
public abstract LSResourceResolver getResourceResolver ()
```

Gets the current `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver` set to this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver` | This method returns the object that was last set through the `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setResourceResolver(org.w3c.dom.ls.LSResourceResolver)` method, or null if that method has never been called since this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` has created. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setErrorHandler(org.xml.sax.ErrorHandler)`

### isSchemaLanguageSupported

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

```
public abstract boolean isSchemaLanguageSupported (String schemaLanguage)
```

<br />

Is specified schema supported by this `SchemaFactory`?

<br />

<br />

| Parameters ||
|---|---|
| `schemaLanguage` | `String`: Specifies the schema language which the returned `SchemaFactory` will understand. `schemaLanguage` must specify a [valid](https://developer.android.com/reference/javax/xml/validation/SchemaFactory#schemaLanguage) schema language. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if `SchemaFactory` supports `schemaLanguage`, else `false`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `schemaLanguage.length() == 0` or `schemaLanguage` does not specify a [valid](https://developer.android.com/reference/javax/xml/validation/SchemaFactory#schemaLanguage) schema language. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `schemaLanguage` is `null`. |

### newInstance

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

```
public static SchemaFactory newInstance (String schemaLanguage, 
                String factoryClassName, 
                ClassLoader classLoader)
```

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

<br />

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

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

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `factoryClassName` is not available, cannot be instantiated, or doesn't support `schemaLanguage`. |

### newInstance

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

```
public static SchemaFactory newInstance (String schemaLanguage)
```

<br />

Lookup an implementation of the `SchemaFactory` that supports the specified
schema language and return it.

To find a `SchemaFactory` object for a given schema language,
this method looks the following places in the following order
where "the class loader" refers to the context class loader:

1. If the system property `"javax.xml.validation.SchemaFactory:*schemaLanguage*"` is present (where *schemaLanguage* is the parameter to this method), then its value is read as a class name. The method will try to create a new instance of this class by using the class loader, and returns it if it is successfully created.
2. `$java.home/lib/jaxp.properties` is read and the value associated with the key being the system property above is looked for. If present, the value is processed just like above.
3. The class loader is asked for service provider provider-configuration files matching
   `javax.xml.validation.SchemaFactory` in the resource directory META-INF/services.
   See the JAR File Specification for file format and parsing rules.
   Each potential service provider is required to implement the method:

              https://developer.android.com/reference/javax/xml/validation/SchemaFactory#isSchemaLanguageSupported(java.lang.String)
           
   The first service provider found in class loader order that supports the specified schema language is returned.
4. Platform default `SchemaFactory` is located in a implementation specific way. There must be a platform default `SchemaFactory` for W3C XML Schema.

If everything fails, `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown.

**Tip for Trouble-shooting:**

See `https://developer.android.com/reference/java/util/Properties#load(java.io.InputStream)` for
exactly how a property file is parsed. In particular, colons ':'
need to be escaped in a property file, so make sure schema language
URIs are properly escaped in it. For example:

```
http\://www.w3.org/2001/XMLSchema=org.acme.foo.XSSchemaFactory
```

<br />

<br />

| Parameters ||
|---|---|
| `schemaLanguage` | `String`: Specifies the schema language which the returned SchemaFactory will understand. See [the list of available schema languages](https://developer.android.com/reference/javax/xml/validation/SchemaFactory#schemaLanguage) for the possible values. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` | New instance of a `SchemaFactory` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If no implementation of the schema language is available. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If the schemaLanguage parameter is null. |

### newSchema

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

```
public Schema newSchema (File schema)
```

<br />

Parses the specified `File` as a schema and returns it as a `Schema`.

This is a convenience method for `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newSchema(javax.xml.transform.Source)`.

<br />

<br />

| Parameters ||
|---|---|
| `schema` | `File`: File that represents a schema. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/validation/Schema` | New `Schema` from parsing `schema`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if schema is null. |
| `https://developer.android.com/reference/org/xml/sax/SAXException` | If a SAX error occurs during parsing. |

### newSchema

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

```
public Schema newSchema (Source schema)
```

<br />

Parses the specified source as a schema and returns it as a schema.

This is a convenience method for `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newSchema(javax.xml.transform.Source[])`.

<br />

<br />

| Parameters ||
|---|---|
| `schema` | `Source`: Source that represents a schema. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/validation/Schema` | New `Schema` from parsing `schema`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if schema is null. |
| `https://developer.android.com/reference/org/xml/sax/SAXException` | If a SAX error occurs during parsing. |

### newSchema

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

```
public abstract Schema newSchema ()
```

Creates a special `https://developer.android.com/reference/javax/xml/validation/Schema` object.


The exact semantics of the returned `https://developer.android.com/reference/javax/xml/validation/Schema` object depends
on the schema language that this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` is created
for.


Also, implementations are allowed to use implementation-specific
property/feature to alter the semantics of this method.


## W3C XML Schema 1.0


For XML Schema, this method creates a `https://developer.android.com/reference/javax/xml/validation/Schema` object that
performs validation by using location hints specified in documents.


The returned `https://developer.android.com/reference/javax/xml/validation/Schema` object assumes that if documents
refer to the same URL in the schema location hints,
they will always resolve to the same schema document. This
assumption allows implementations to reuse parsed results of
schema documents so that multiple validations against the same
schema will run faster.


Note that the use of schema location hints introduces a
vulnerability to denial-of-service attacks.


## RELAX NG


RELAX NG does not support this operation.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/validation/Schema` | Always return non-null valid `https://developer.android.com/reference/javax/xml/validation/Schema` object. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | If this operation is not supported by the callee. |
| `https://developer.android.com/reference/org/xml/sax/SAXException` | If this operation is supported but failed for some reason. |

### newSchema

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

```
public abstract Schema newSchema (Source[] schemas)
```

Parses the specified source(s) as a schema and returns it as a schema.


The callee will read all the `https://developer.android.com/reference/javax/xml/transform/Source`s and combine them into a
single schema. The exact semantics of the combination depends on the schema
language that this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` object is created for.


When an `https://developer.android.com/reference/org/xml/sax/ErrorHandler` is set, the callee will report all the errors
found in sources to the handler. If the handler throws an exception, it will
abort the schema compilation and the same exception will be thrown from
this method. Also, after an error is reported to a handler, the callee is allowed
to abort the further processing by throwing it. If an error handler is not set,
the callee will throw the first error it finds in the sources.

## W3C XML Schema 1.0


The resulting schema contains components from the specified sources.
The same result would be achieved if all these sources were
imported, using appropriate values for schemaLocation and namespace,
into a single schema document with a different targetNamespace
and no components of its own, if the import elements were given
in the same order as the sources. Section 4.2.3 of the XML Schema
recommendation describes the options processors have in this
regard. While a processor should be consistent in its treatment of
JAXP schema sources and XML Schema imports, the behavior between
JAXP-compliant parsers may vary; in particular, parsers may choose
to ignore all but the first \<import\> for a given namespace,
regardless of information provided in schemaLocation.


If the parsed set of schemas includes error(s) as
specified in the section 5.1 of the XML Schema spec, then
the error must be reported to the `https://developer.android.com/reference/org/xml/sax/ErrorHandler`.

## RELAX NG

For RELAX NG, this method must throw `https://developer.android.com/reference/java/lang/UnsupportedOperationException`
if schemas.length!=1.

<br />

| Parameters ||
|---|---|
| `schemas` | `Source`: inputs to be parsed. `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` is required to recognize `https://developer.android.com/reference/javax/xml/transform/stream/StreamSource`, `https://developer.android.com/reference/javax/xml/transform/sax/SAXSource`, and `https://developer.android.com/reference/javax/xml/transform/dom/DOMSource`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/validation/Schema` | Always return a non-null valid `https://developer.android.com/reference/javax/xml/validation/Schema` object. Note that when an error has been reported, there is no guarantee that the returned `https://developer.android.com/reference/javax/xml/validation/Schema` object is meaningful. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any item in the array is not recognized by this method. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If the `schemas` parameter itself is null or any item in the array is null. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | If the schema language doesn't support this operation. |
| `https://developer.android.com/reference/org/xml/sax/SAXException` | If an error is found during processing the specified inputs. When an `https://developer.android.com/reference/org/xml/sax/ErrorHandler` is set, errors are reported to there first. See `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#setErrorHandler(org.xml.sax.ErrorHandler)`. |

### newSchema

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

```
public Schema newSchema (URL schema)
```

<br />

Parses the specified `URL` as a schema and returns it as a `Schema`.

This is a convenience method for `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#newSchema(javax.xml.transform.Source)`.

<br />

<br />

| Parameters ||
|---|---|
| `schema` | `URL`: `URL` that represents a schema. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/validation/Schema` | New `Schema` from parsing `schema`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if schema is null. |
| `https://developer.android.com/reference/org/xml/sax/SAXException` | If a SAX error occurs during parsing. |

### setErrorHandler

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

```
public abstract void setErrorHandler (ErrorHandler errorHandler)
```

Sets the `https://developer.android.com/reference/org/xml/sax/ErrorHandler` to receive errors encountered
during the `newSchema` method invocation.


Error handler can be used to customize the error handling process
during schema parsing. When an `https://developer.android.com/reference/org/xml/sax/ErrorHandler` is set,
errors found during the parsing of schemas will be first sent
to the `https://developer.android.com/reference/org/xml/sax/ErrorHandler`.


The error handler can abort the parsing of a schema immediately
by throwing `https://developer.android.com/reference/org/xml/sax/SAXException` from the handler. Or for example
it can print an error to the screen and try to continue the
processing by returning normally from the `https://developer.android.com/reference/org/xml/sax/ErrorHandler`


If any `https://developer.android.com/reference/java/lang/Throwable` (or instances of its derived classes)
is thrown from an `https://developer.android.com/reference/org/xml/sax/ErrorHandler`,
the caller of the `newSchema` method will be thrown
the same `https://developer.android.com/reference/java/lang/Throwable` object.


`https://developer.android.com/reference/javax/xml/validation/SchemaFactory` is not allowed to
throw `https://developer.android.com/reference/org/xml/sax/SAXException` without first reporting it to
`https://developer.android.com/reference/org/xml/sax/ErrorHandler`.


Applications can call this method even during a `https://developer.android.com/reference/javax/xml/validation/Schema`
is being parsed.


When the `https://developer.android.com/reference/org/xml/sax/ErrorHandler` is null, the implementation will
behave as if the following `https://developer.android.com/reference/org/xml/sax/ErrorHandler` is set:

    class DraconianErrorHandler implements https://developer.android.com/reference/org/xml/sax/ErrorHandler {
        public void fatalError( https://developer.android.com/reference/org/xml/sax/SAXParseException e ) throws https://developer.android.com/reference/org/xml/sax/SAXException {
            throw e;
        }
        public void error( https://developer.android.com/reference/org/xml/sax/SAXParseException e ) throws https://developer.android.com/reference/org/xml/sax/SAXException {
            throw e;
        }
        public void warning( https://developer.android.com/reference/org/xml/sax/SAXParseException e ) throws https://developer.android.com/reference/org/xml/sax/SAXException {
            // noop
        }
    }


When a new `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` object is created, initially
this field is set to null. This field will *NOT* be
inherited to `https://developer.android.com/reference/javax/xml/validation/Schema`s, `https://developer.android.com/reference/javax/xml/validation/Validator`s, or
`https://developer.android.com/reference/javax/xml/validation/ValidatorHandler`s that are created from this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory`.

<br />

| Parameters ||
|---|---|
| `errorHandler` | `ErrorHandler`: A new error handler to be set. This parameter can be null. <br /> |

### setFeature

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

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

Set the value of a feature flag.


Feature can be used to control the way a `https://developer.android.com/reference/javax/xml/validation/SchemaFactory`
parses schemas, although `https://developer.android.com/reference/javax/xml/validation/SchemaFactory`s are not required
to recognize any specific feature names.

The feature name is any fully-qualified URI. It is
possible for a `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` to expose a feature value but
to be unable to change the current value.

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/validation/SchemaFactory#setErrorHandler(org.xml.sax.ErrorHandler)`.
- `false`: the implementation will processing XML according to the XML specifications without regard to possible implementation limits.

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String`: The feature name, which is a non-null fully-qualified URI. <br /> |
| `value` | `boolean`: The requested value of the feature (true or false). <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the name parameter is null. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotRecognizedException` | If the feature value can't be assigned or retrieved. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotSupportedException` | When the `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` recognizes the feature name but cannot set the requested value. |

**See also:**

- `https://developer.android.com/reference/javax/xml/validation/SchemaFactory#getFeature(java.lang.String)`

### setProperty

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

```
public void setProperty (String name, 
                Object object)
```

Set the value of a property.

The property name is any fully-qualified URI. It is
possible for a `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` to recognize a property name but
to be unable to change the current value.

`https://developer.android.com/reference/javax/xml/validation/SchemaFactory`s are not required to recognize setting
any specific property names.

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String`: The property name, which is a non-null fully-qualified URI. <br /> |
| `object` | `Object`: The requested value for the property. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the name parameter is null. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotRecognizedException` | If the property value can't be assigned or retrieved. |
| `https://developer.android.com/reference/org/xml/sax/SAXNotSupportedException` | When the `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` recognizes the property name but cannot set the requested value. |

### setResourceResolver

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

```
public abstract void setResourceResolver (LSResourceResolver resourceResolver)
```

Sets the `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver` to customize
resource resolution when parsing schemas.


`https://developer.android.com/reference/javax/xml/validation/SchemaFactory` uses a `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver`
when it needs to locate external resources while parsing schemas,
although exactly what constitutes "locating external resources" is
up to each schema language. For example, for W3C XML Schema,
this includes files \<include\>d or \<import\>ed,
and DTD referenced from schema files, etc.


Applications can call this method even during a `https://developer.android.com/reference/javax/xml/validation/Schema`
is being parsed.


When the `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver` is null, the implementation will
behave as if the following `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver` is set:

    class DumbDOMResourceResolver implements https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver {
        public https://developer.android.com/reference/org/w3c/dom/ls/LSInput resolveResource(
            String publicId, String systemId, String baseURI) {

            return null; // always return null
        }
    }


If a `https://developer.android.com/reference/org/w3c/dom/ls/LSResourceResolver` throws a `https://developer.android.com/reference/java/lang/RuntimeException`
(or instances of its derived classes),
then the `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` will abort the parsing and
the caller of the `newSchema` method will receive
the same `https://developer.android.com/reference/java/lang/RuntimeException`.


When a new `https://developer.android.com/reference/javax/xml/validation/SchemaFactory` object is created, initially
this field is set to null. This field will *NOT* be
inherited to `https://developer.android.com/reference/javax/xml/validation/Schema`s, `https://developer.android.com/reference/javax/xml/validation/Validator`s, or
`https://developer.android.com/reference/javax/xml/validation/ValidatorHandler`s that are created from this `https://developer.android.com/reference/javax/xml/validation/SchemaFactory`.

<br />

| Parameters ||
|---|---|
| `resourceResolver` | `LSResourceResolver`: A new resource resolver to be set. This parameter can be null. <br /> |