# Validator

public abstract class **Validator** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
<br />

A processor that checks an XML document against `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Schema.html`.


A validator is a thread-unsafe and non-reentrant object.
In other words, it is the application's responsibility to make
sure that one `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` object is not used from
more than one thread at any given time, and while the validate
method is invoked, applications may not recursively call
the validate method.


Note that while the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#validate(javax.xml.transform.Source)` and `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#validate(javax.xml.transform.Source,%20javax.xml.transform.Result)`
methods take a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html` instance, the `Source`
instance must be a `SAXSource`, `DOMSource`, `StAXSource` or `StreamSource`.

### Protected Constructor Summary

|---|---|
|   | [Validator](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#Validator())() Constructor for derived classes. |

### Public Method Summary

|---|---|
| abstract [ErrorHandler](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html) | [getErrorHandler](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#getErrorHandler())() Gets the current `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` set to this `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html`. |
| boolean | [getFeature](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#getFeature(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Look up the value of a feature flag. |
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [getProperty](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#getProperty(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Look up the value of a property. |
| abstract [LSResourceResolver](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html) | [getResourceResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#getResourceResolver())() Gets the current `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html` set to this `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html`. |
| abstract void | [reset](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#reset())() Reset this `Validator` to its original configuration. |
| abstract void | [setErrorHandler](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setErrorHandler(org.xml.sax.ErrorHandler))([ErrorHandler](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html) errorHandler) Sets the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` to receive errors encountered during the `validate` method invocation. |
| void | [setFeature](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setFeature(java.lang.String,%20boolean))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, boolean value) Set the value of a feature flag. |
| void | [setProperty](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setProperty(java.lang.String,%20java.lang.Object))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) object) Set the value of a property. |
| abstract void | [setResourceResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setResourceResolver(org.w3c.dom.ls.LSResourceResolver))([LSResourceResolver](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html) resourceResolver) Sets the `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html` to customize resource resolution while in a validation episode. |
| void | [validate](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#validate(javax.xml.transform.Source))([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source) Validates the specified input. |
| abstract void | [validate](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#validate(javax.xml.transform.Source,%20javax.xml.transform.Result))([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source, [Result](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Result.html) result) Validates the specified input and send the augmented validation result to the specified output. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Protected Constructors

#### protected
**Validator**
()

Constructor for derived classes.


The constructor does nothing.


Derived classes must create `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` objects that have
null `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` and
null `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html`.

## Public Methods

#### public abstract [ErrorHandler](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html)
**getErrorHandler**
()

Gets the current `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` set to this `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html`.

##### Returns

- This method returns the object that was last set through the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setErrorHandler(org.xml.sax.ErrorHandler)` method, or null if that method has never been called since this `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` has created.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setErrorHandler(org.xml.sax.ErrorHandler)`

#### public boolean
**getFeature**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name)

Look up the value of a feature flag.

The feature name is any fully-qualified URI. It is
possible for a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` to recognize a feature name but
temporarily be unable to return its value.
Some feature values may be available only in specific
contexts, such as before, during, or after a validation.

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

<br />

##### Parameters

| name | The feature name, which is a non-null fully-qualified URI. |
|---|---|

##### Returns

- The current value of the feature (true or false).

##### Throws

| [SAXNotRecognizedException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXNotRecognizedException.html) | If the feature value can't be assigned or retrieved. |
| [SAXNotSupportedException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXNotSupportedException.html) | When the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` recognizes the feature name but cannot determine its value at this time. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | When the name parameter is null. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setFeature(java.lang.String,%20boolean)`

#### public [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)
**getProperty**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name)

Look up the value of a property.

The property name is any fully-qualified URI. It is
possible for a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` to recognize a property name but
temporarily be unable to return its value.
Some property values may be available only in specific
contexts, such as before, during, or after a validation.

`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html`s are not required to recognize any specific
property names.

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

<br />

##### Parameters

| name | The property name, which is a non-null fully-qualified URI. |
|---|---|

##### Returns

- The current value of the property.

##### Throws

| [SAXNotRecognizedException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXNotRecognizedException.html) | If the property value can't be assigned or retrieved. |
| [SAXNotSupportedException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXNotSupportedException.html) | When the XMLReader recognizes the property name but cannot determine its value at this time. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | When the name parameter is null. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setProperty(java.lang.String,%20java.lang.Object)`

#### public abstract [LSResourceResolver](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html)
**getResourceResolver**
()

Gets the current `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html` set to this `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html`.

##### Returns

- This method returns the object that was last set through the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setResourceResolver(org.w3c.dom.ls.LSResourceResolver)` method, or null if that method has never been called since this `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` has created.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setErrorHandler(org.xml.sax.ErrorHandler)`

#### public abstract void
**reset**
()

<br />

Reset this `Validator` to its original configuration.

`Validator` is reset to the same state as when it was created with
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Schema.html#newValidator()`.
`reset()` is designed to allow the reuse of existing `Validator`s
thus saving resources associated with the creation of new `Validator`s.

The reset `Validator` is not guaranteed to have the same `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html` or `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html`
`Object`s, e.g. `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object)`. It is guaranteed to have a functionally equal
`LSResourceResolver` and `ErrorHandler`.

<br />

#### public abstract void
**setErrorHandler**
([ErrorHandler](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html) errorHandler)

Sets the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` to receive errors encountered
during the `validate` method invocation.


Error handler can be used to customize the error handling process
during a validation. When an `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` is set,
errors found during the validation will be first sent
to the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html`.


The error handler can abort further validation immediately
by throwing `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html` from the handler. Or for example
it can print an error to the screen and try to continue the
validation by returning normally from the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html`


If any `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html` is thrown from an `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html`,
the caller of the `validate` method will be thrown
the same `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html` object.


`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` is not allowed to
throw `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html` without first reporting it to
`https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html`.


When the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` is null, the implementation will
behave as if the following `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` is set:

     class DraconianErrorHandler implements https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html {
         public void fatalError( https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXParseException.html e ) throws https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html {
             throw e;
         }
         public void error( https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXParseException.html e ) throws https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html {
             throw e;
         }
         public void warning( https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXParseException.html e ) throws https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html {
             // noop
         }
     }
     

When a new `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` object is created, initially
this field is set to null.

##### Parameters

| errorHandler | A new error handler to be set. This parameter can be null. |
|---|---|

#### public void
**setFeature**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, boolean value)

Set the value of a feature flag.


Feature can be used to control the way a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html`
parses schemas, although `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html`s are not required
to recognize any specific property names.

The feature name is any fully-qualified URI. It is
possible for a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` to expose a feature value but
to be unable to change the current value.
Some feature values may be immutable or mutable only
in specific contexts, such as before, during, or after
a validation.

<br />

##### Parameters

| name | The feature name, which is a non-null fully-qualified URI. |
| value | The requested value of the feature (true or false). |
|---|---|

##### Throws

| [SAXNotRecognizedException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXNotRecognizedException.html) | If the feature value can't be assigned or retrieved. |
| [SAXNotSupportedException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXNotSupportedException.html) | When the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` recognizes the feature name but cannot set the requested value. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | When the name parameter is null. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#getFeature(java.lang.String)`

#### public void
**setProperty**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) object)

Set the value of a property.

The property name is any fully-qualified URI. It is
possible for a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` to recognize a property name but
to be unable to change the current value.
Some property values may be immutable or mutable only
in specific contexts, such as before, during, or after
a validation.

`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html`s are not required to recognize setting
any specific property names.

<br />

##### Parameters

| name | The property name, which is a non-null fully-qualified URI. |
| object | The requested value for the property. |
|---|---|

##### Throws

| [SAXNotRecognizedException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXNotRecognizedException.html) | If the property value can't be assigned or retrieved. |
| [SAXNotSupportedException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXNotSupportedException.html) | When the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` recognizes the property name but cannot set the requested value. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | When the name parameter is null. |
|---|---|

#### public abstract void
**setResourceResolver**
([LSResourceResolver](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html) resourceResolver)

Sets the `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html` to customize
resource resolution while in a validation episode.


`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` uses a `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html`
when it needs to locate external resources while a validation,
although exactly what constitutes "locating external resources" is
up to each schema language.


When the `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html` is null, the implementation will
behave as if the following `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html` is set:

     class DumbLSResourceResolver implements https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html {
         public https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSInput.html resolveResource(
             String publicId, String systemId, String baseURI) {

             return null; // always return null
         }
     }
     

If a `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/ls/LSResourceResolver.html` throws a `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimeException.html`
(or instances of its derived classes),
then the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` will abort the parsing and
the caller of the `validate` method will receive
the same `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimeException.html`.


When a new `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html` object is created, initially
this field is set to null.

##### Parameters

| resourceResolver | A new resource resolver to be set. This parameter can be null. |
|---|---|

#### public void
**validate**
([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source)

Validates the specified input.


This is just a convenience method of:

```
 validate(source,null);
 
```

<br />

##### Parameters

| source |   |
|---|---|

##### Throws

| [SAXException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html) |   |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) |   |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#setErrorHandler(org.xml.sax.ErrorHandler)`

#### public abstract void
**validate**
([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source, [Result](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Result.html) result)

Validates the specified input and send the augmented validation
result to the specified output.


This method places the following restrictions on the types of
the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html`/`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Result.html` accepted.

#### `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html`/`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Result.html` accepted:

|   | `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/sax/SAXSource.html` | `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/dom/DOMSource.html` | `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/stream/StreamSource.html` |
|---|---|---|---|---|
| null | OK | OK | OK | OK |
| `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/sax/SAXResult.html` | OK | Err | Err | Err |
| `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/dom/DOMResult.html` | Err | OK | Err | Err |
| `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/stream/StreamResult.html` | Err | Err | Err | OK |


To validate one `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html` into another kind of `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Result.html`, use the identity transformer
(see `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#newTransformer()`).


Errors found during the validation is sent to the specified
`https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html`.


If a document is valid, or if a document contains some errors
but none of them were fatal and the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` didn't
throw any exception, then the method returns normally.

##### Parameters

| source | XML to be validated. Must not be null. |
| result | The `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Result.html` object that receives (possibly augmented) XML. This parameter can be null if the caller is not interested in it. Note that when a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/dom/DOMResult.html` is used, a validator might just pass the same DOM node from `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/dom/DOMSource.html` to `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/dom/DOMResult.html` (in which case source.getNode()==result.getNode()), it might copy the entire DOM tree, or it might alter the node given by the source. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | If the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Result.html` type doesn't match the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html` type, or if the specified source is not a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/sax/SAXSource.html`, `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/dom/DOMSource.html` or `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/stream/StreamSource.html`. |
| [SAXException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html) | If the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` throws a `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html` or if a fatal error is found and the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` returns normally. |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If the validator is processing a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/sax/SAXSource.html` and the underlying `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/XMLReader.html` throws an `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html`. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If the source parameter is null. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Validator.html#validate(javax.xml.transform.Source)`