SchemaFactory

public abstract class SchemaFactory extends Object

Factory that creates Schema objects. Entry-point to the validation API.

SchemaFactory is a schema compiler. It reads external representations of schemas and prepares them for validation.

The 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 SchemaFactory object at any given moment. Implementations are encouraged to mark methods as synchronized to protect themselves from broken clients.

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 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
W3C_XML_SCHEMA_NS_URI ("http://www.w3.org/2001/XMLSchema") W3C XML Schema 1.0
RELAXNG_NS_URI ("http://relaxng.org/ns/structure/1.0") RELAX NG 1.0

Protected Constructor Summary

SchemaFactory()

Constructor for derived classes.

Public Method Summary

abstract ErrorHandler
getErrorHandler()
Gets the current ErrorHandler set to this SchemaFactory.
boolean
getFeature(String name)
Look up the value of a feature flag.
Object
getProperty(String name)
Look up the value of a property.
abstract LSResourceResolver
getResourceResolver()
Gets the current LSResourceResolver set to this SchemaFactory.
abstract boolean
isSchemaLanguageSupported(String schemaLanguage)

Is specified schema supported by this SchemaFactory?

static SchemaFactory
newInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader)
Returns an instance of the named implementation of SchemaFactory.
static SchemaFactory
newInstance(String schemaLanguage)

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

Schema
newSchema(File schema)

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

Schema
newSchema(Source schema)

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

abstract Schema
newSchema()
Creates a special Schema object.
abstract Schema
newSchema(Source[] schemas)
Parses the specified source(s) as a schema and returns it as a schema.
Schema
newSchema(URL schema)

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

abstract void
setErrorHandler(ErrorHandler errorHandler)
Sets the ErrorHandler to receive errors encountered during the newSchema method invocation.
void
setFeature(String name, boolean value)
Set the value of a feature flag.
void
setProperty(String name, Object object)
Set the value of a property.
abstract void
setResourceResolver(LSResourceResolver resourceResolver)
Sets the LSResourceResolver to customize resource resolution when parsing schemas.

Inherited Method Summary

Protected Constructors

protected SchemaFactory ()

Constructor for derived classes.

The constructor does nothing.

Derived classes must create SchemaFactory objects that have null ErrorHandler and null LSResourceResolver.

Public Methods

public abstract ErrorHandler getErrorHandler ()

Gets the current ErrorHandler set to this SchemaFactory.

Returns
  • This method returns the object that was last set through the