Xerces2 Implementation: Class XMLSchemaFactory

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xerces.jaxp.validation
Class XMLSchemaFactory

    java.lang.Object
      |
      +--javax.xml.validation.SchemaFactory
            |
            +--org.apache.xerces.jaxp.validation.XMLSchemaFactory

public final class XMLSchemaFactory
extends javax.xml.validation.SchemaFactory

`SchemaFactory` for XML Schema.

Version:
  $Id: XMLSchemaFactory.java 1027335 2010-10-26 01:37:38Z mrglavas $
Author:
  Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)

Constructor Summary
`XMLSchemaFactory()`

Method Summary
`org.xml.sax.ErrorHandler` | `getErrorHandler()` Gets the current `ErrorHandler` set to this `SchemaFactory`.
`boolean` | `getFeature(java.lang.String name)` Look up the value of a feature flag.
`java.lang.Object` | `getProperty(java.lang.String name)` Look up the value of a property.
`org.w3c.dom.ls.LSResourceResolver` | `getResourceResolver()` Gets the current `LSResourceResolver` set to this `SchemaFactory`.
`boolean` | `isSchemaLanguageSupported(java.lang.String schemaLanguage)` Is specified schema supported by this `SchemaFactory`?
`javax.xml.validation.Schema` | `newSchema()` Creates a special `Schema` object.
`javax.xml.validation.Schema` | `newSchema(javax.xml.transform.Source[] schemas)` Parses the specified source(s) as a schema and returns it as a schema.
`javax.xml.validation.Schema` | `newSchema(org.apache.xerces.xni.grammars.XMLGrammarPool pool)`
`void` | `setErrorHandler(org.xml.sax.ErrorHandler errorHandler)` Sets the `ErrorHandler` to receive errors encountered during the `newSchema` method invocation.
`void` | `setFeature(java.lang.String name, boolean value)` Set the value of a feature flag.
`void` | `setProperty(java.lang.String name, java.lang.Object object)` Set the value of a property.
`void` | `setResourceResolver(org.w3c.dom.ls.LSResourceResolver resourceResolver)` Sets the `LSResourceResolver` to customize resource resolution when parsing schemas.

Methods inherited from class javax.xml.validation.SchemaFactory
`newInstance, newInstance, newSchema, newSchema, newSchema`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XMLSchemaFactory

    public XMLSchemaFactory()

Method Detail

### isSchemaLanguageSupported

    public boolean isSchemaLanguageSupported(java.lang.String schemaLanguage)

  Is specified schema supported by this `SchemaFactory`?

  Overrides:
    `isSchemaLanguageSupported` in class `javax.xml.validation.SchemaFactory`
  Parameters:
    `schemaLanguage` - Specifies the schema language which the returned `SchemaFactory` will understand. `schemaLanguage` must specify a valid schema language.
  Returns:
    `true` if `SchemaFactory` supports `schemaLanguage`, else `false`.
  Throws:
    `NullPointerException` - If `schemaLanguage` is `null`.
    `java.lang.IllegalArgumentException` - If `schemaLanguage.length() == 0` or `schemaLanguage` does not specify a valid schema language.

### getResourceResolver

    public org.w3c.dom.ls.LSResourceResolver getResourceResolver()

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Gets the current `LSResourceResolver` set to this `SchemaFactory`.
  Overrides:
    `getResourceResolver` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Returns:
    This method returns the object that was last set through the `SchemaFactory.setResourceResolver(LSResourceResolver)` method, or null if that method has never been called since this `SchemaFactory` has created.
  See Also:
    `SchemaFactory.setErrorHandler(ErrorHandler)`

### setResourceResolver

    public void setResourceResolver(org.w3c.dom.ls.LSResourceResolver resourceResolver)

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Sets the `LSResourceResolver` to customize resource resolution when parsing schemas.

  `SchemaFactory` uses a `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 `Schema` is being parsed.

  When the `LSResourceResolver` is null, the implementation will behave as if the following `LSResourceResolver` is set:

       class DumbDOMResourceResolver implements LSResourceResolver {
           public LSInput resolveResource(
               String publicId, String systemId, String baseURI) {

               return null; // always return null
           }
       }

  If a `LSResourceResolver` throws a `RuntimeException` (or instances of its derived classes), then the `SchemaFactory` will abort the parsing and the caller of the `newSchema` method will receive the same `RuntimeException`.

  When a new `SchemaFactory` object is created, initially this field is set to null. This field will NOT be inherited to `Schema`s, `Validator`s, or `ValidatorHandler`s that are created from this `SchemaFactory`.

  Overrides:
    `setResourceResolver` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Parameters:
    `resourceResolver` - A new resource resolver to be set. This parameter can be null.

### getErrorHandler

    public org.xml.sax.ErrorHandler getErrorHandler()

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Gets the current `ErrorHandler` set to this `SchemaFactory`.
  Overrides:
    `getErrorHandler` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Returns:
    This method returns the object that was last set through the `SchemaFactory.setErrorHandler(ErrorHandler)` method, or null if that method has never been called since this `SchemaFactory` has created.
  See Also:
    `SchemaFactory.setErrorHandler(ErrorHandler)`

### setErrorHandler

    public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Sets the `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 `ErrorHandler` is set, errors found during the parsing of schemas will be first sent to the `ErrorHandler`.

  The error handler can abort the parsing of a schema immediately by throwing `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 `ErrorHandler`

  If any `Throwable` (or instances of its derived classes) is thrown from an `ErrorHandler`, the caller of the `newSchema` method will be thrown the same `Throwable` object.

  `SchemaFactory` is not allowed to throw `SAXException` without first reporting it to `ErrorHandler`.

  Applications can call this method even during a `Schema` is being parsed.

  When the `ErrorHandler` is null, the implementation will behave as if the following `ErrorHandler` is set:

       class DraconianErrorHandler implements ErrorHandler {
           public void fatalError( SAXParseException e ) throws SAXException {
               throw e;
           }
           public void error( SAXParseException e ) throws SAXException {
               throw e;
           }
           public void warning( SAXParseException e ) throws SAXException {
               // noop
           }
       }

  When a new `SchemaFactory` object is created, initially this field is set to null. This field will NOT be inherited to `Schema`s, `Validator`s, or `ValidatorHandler`s that are created from this `SchemaFactory`.

  Overrides:
    `setErrorHandler` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Parameters:
    `errorHandler` - A new error handler to be set. This parameter can be null.

### newSchema

    public javax.xml.validation.Schema newSchema(javax.xml.transform.Source[] schemas)
                                          throws org.xml.sax.SAXException

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Parses the specified source(s) as a schema and returns it as a schema.

  The callee will read all the `Source`s and combine them into a single schema. The exact semantics of the combination depends on the schema language that this `SchemaFactory` object is created for.

  When an `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 behaviour 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 `ErrorHandler`.

  ## RELAX NG

  For RELAX NG, this method must throw `UnsupportedOperationException` if `schemas.length!=1`.

  Overrides:
    `newSchema` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Parameters:
    `schemas` - inputs to be parsed. `SchemaFactory` is required to recognize `StreamSource`, `SAXSource`, `DOMSource` and `StAXSource`.
  Returns:
    Always return a non-null valid `Schema` object. Note that when an error has been reported, there is no guarantee that the returned `Schema` object is meaningful.
  Throws:
    `org.xml.sax.SAXException` - If an error is found during processing the specified inputs. When an `ErrorHandler` is set, errors are reported to there first. See `SchemaFactory.setErrorHandler(ErrorHandler)`.
    `NullPointerException` - If the `schemas` parameter itself is null or any item in the array is null.
    `java.lang.IllegalArgumentException` - If any item in the array is not recognized by this method.
    `UnsupportedOperationException` - If the schema language doesn't support this operation.

### newSchema

    public javax.xml.validation.Schema newSchema()
                                          throws org.xml.sax.SAXException

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Creates a special `Schema` object.

  The exact semantics of the returned `Schema` object depends on the schema language that this `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 `Schema` object that performs validation by using location hints specified in documents.

  The returned `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.

  Overrides:
    `newSchema` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Returns:
    Always return non-null valid `Schema` object.
  Throws:
    `UnsupportedOperationException` - If this operation is not supported by the callee.
    `org.xml.sax.SAXException` - If this operation is supported but failed for some reason.

### newSchema

    public javax.xml.validation.Schema newSchema(org.apache.xerces.xni.grammars.XMLGrammarPool pool)
                                          throws org.xml.sax.SAXException

### getFeature

    public boolean getFeature(java.lang.String name)
                       throws org.xml.sax.SAXNotRecognizedException,
                              org.xml.sax.SAXNotSupportedException

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Look up the value of a feature flag.

  The feature name is any fully-qualified URI. It is possible for a `SchemaFactory` to recognize a feature name but temporarily be unable to return its value.

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

  Overrides:
    `getFeature` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Parameters:
    `name` - The feature name, which is a non-null fully-qualified URI.
  Returns:
    The current value of the feature (true or false).
  Throws:
    `org.xml.sax.SAXNotRecognizedException` - If the feature value can't be assigned or retrieved.
    `org.xml.sax.SAXNotSupportedException` - When the `SchemaFactory` recognizes the feature name but cannot determine its value at this time.
    `NullPointerException` - if the name parameter is null.
  See Also:
    `SchemaFactory.setFeature(String, boolean)`

### getProperty

    public java.lang.Object getProperty(java.lang.String name)
                                 throws org.xml.sax.SAXNotRecognizedException,
                                        org.xml.sax.SAXNotSupportedException

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Look up the value of a property.

  The property name is any fully-qualified URI. It is possible for a `SchemaFactory` to recognize a property name but temporarily be unable to return its value.

  `SchemaFactory`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.

  Overrides:
    `getProperty` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Parameters:
    `name` - The property name, which is a non-null fully-qualified URI.
  Returns:
    The current value of the property.
  Throws:
    `org.xml.sax.SAXNotRecognizedException` - If the property value can't be assigned or retrieved.
    `org.xml.sax.SAXNotSupportedException` - When the XMLReader recognizes the property name but cannot determine its value at this time.
    `NullPointerException` - if the name parameter is null.
  See Also:
    `SchemaFactory.setProperty(String, Object)`

### setFeature

    public void setFeature(java.lang.String name,
                           boolean value)
                    throws org.xml.sax.SAXNotRecognizedException,
                           org.xml.sax.SAXNotSupportedException

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Set the value of a feature flag.

  Feature can be used to control the way a `SchemaFactory` parses schemas, although `SchemaFactory`s are not required to recognize any specific feature names.

  The feature name is any fully-qualified URI. It is possible for a `SchemaFactory` to expose a feature value but to be unable to change the current value.

  All implementations are required to support the `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 `ErrorHandler.fatalError(SAXParseException exception)`. See `SchemaFactory.setErrorHandler(ErrorHandler errorHandler)`.
  - `false`: the implementation will processing XML according to the XML specifications without regard to possible implementation limits.
  Overrides:
    `setFeature` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Parameters:
    `name` - The feature name, which is a non-null fully-qualified URI.
    `value` - The requested value of the feature (true or false).
  Throws:
    `org.xml.sax.SAXNotRecognizedException` - If the feature value can't be assigned or retrieved.
    `org.xml.sax.SAXNotSupportedException` - When the `SchemaFactory` recognizes the feature name but cannot set the requested value.
    `NullPointerException` - if the name parameter is null.
  See Also:
    `SchemaFactory.getFeature(String)`

### setProperty

    public void setProperty(java.lang.String name,
                            java.lang.Object object)
                     throws org.xml.sax.SAXNotRecognizedException,
                            org.xml.sax.SAXNotSupportedException

  Description copied from class: `javax.xml.validation.SchemaFactory`
  Set the value of a property.

  The property name is any fully-qualified URI. It is possible for a `SchemaFactory` to recognize a property name but to be unable to change the current value.

  `SchemaFactory`s are not required to recognize setting any specific property names.

  Overrides:
    `setProperty` in class `javax.xml.validation.SchemaFactory`
  Following copied from class: `javax.xml.validation.SchemaFactory`
  Parameters:
    `name` - The property name, which is a non-null fully-qualified URI.
    `object` - The requested value for the property.
  Throws:
    `org.xml.sax.SAXNotRecognizedException` - If the property value can't be assigned or retrieved.
    `org.xml.sax.SAXNotSupportedException` - When the `SchemaFactory` recognizes the property name but cannot set the requested value.
    `NullPointerException` - if the name parameter is null.

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.