SchemaTypeLoader Interface

com.bea.xml
SchemaTypeLoader Interface

public interface SchemaTypeLoader

Represents a searchable set of XML Schema component definitions.

SchemaTypeLoader is somewhat analogous to ClassLoader, because it is responsible for finding SchemaComponent definitions by name, yet it is not responsible for being able to enumerate all the component definitons available. (If you wish to enumerate component definitions, see SchemaTypeSystem.) There are some ways in which SchemaTypeSystems are dissimilar from ClassLoaders, however. Since XML Schema has a number of instance-oriented typing mechanisms (such as wildcards) that do not exist in Java, a SchemaTypeLoader is not associated with a type; instead, a SchemaTypeLoader is associated with each XML instance.

Every XML instance is loaded within the context of a SchemaTypeLoader; the SchemaTypeLoader for an instance is used to resolve all type definitions within the instance and for applying type-sensitive methods such as XmlObject.validate().

Normally the SchemaTypeLoader being used for all instances is the context type loader (that is, the SchemaTypeLoader returned from XmlBeans.getContextTypeLoader()). The context type loader consults the thread's context ClassLoader (see Thread.getContextClassLoader()) to find schema type defintions that are available on the classpath. The net result is that you can use schema types simply by putting their compiled schema JARs on your classpath. If you wish to load instances using a different SchemaTypeLoader, then you must call SchemaTypeLoader.parse(String, SchemaType, XmlOptions) methods on the SchemaTypeLoader instance explicitly rather than using the normal convenient Factory methods.

A SchemaTypeLoader can be obtained by dynamically loading XSD files using XmlBeans.loadXsd(XmlObject[]), or by assembling other SchemaTypeLoaders or SchemaTypeSystems on a path using XmlBeans.typeLoaderUnion(SchemaTypeLoader[]).

Related Topics

XmlBeans.loadXsd(XmlObject[])
XmlBeans.getContextTypeLoader()
XmlBeans.typeLoaderUnion(SchemaTypeLoader[])
SchemaTypeSystem


All Known Subinterfaces

SchemaTypeSystem

Method Summary

public String
compilePath(String pathExpr, XmlOptions options)
Compiles an XPath
public String
compileQuery(String queryExpr, XmlOptions options)
Compiles an XQuery
public SchemaGlobalAttribute
findAttribute(QName name)
Returns the global attribute defintion with the given name, or null if none.
public SchemaAttributeGroup
findAttributeGroup(QName name)
Returns the attribute group defintion with the given name, or null if none.
public SchemaAttributeGroup.Ref
findAttributeGroupRef(QName name)
Used for on-demand loading.
public SchemaGlobalAttribute.Ref
findAttributeRef(QName name)
Used for on-demand loading.
public SchemaType
findAttributeType(QName name)
Returns the attribute type containing the given attribute name, or null if none.
public SchemaType.Ref
findAttributeTypeRef(QName name)
Used for on-demand loading.
public SchemaType
findDocumentType(QName name)
Returns the document type rooted at the given element name, or null if none.
public SchemaType.Ref
findDocumentTypeRef(QName name)
Used for on-demand loading.
public SchemaGlobalElement
findElement(QName name)
Returns the global element defintion with the given name, or null if none.
public SchemaGlobalElement.Ref
findElementRef(QName name)
Used for on-demand loading.
public SchemaIdentityConstraint.Ref
findIdentityConstraintRef(QName name)
Used for on-demand loading.
public SchemaModelGroup
findModelGroup(QName name)
Returns the model group defintion with the given name, or null if none.
public SchemaModelGroup.Ref
findModelGroupRef(QName name)
Used for on-demand loading.
public SchemaType
findType(QName name)
Returns the type with the given name, or null if none.
public SchemaType.Ref
findTypeRef(QName name)
Used for on-demand loading.
public InputStream
getSourceAsStream(String sourceName)
Loads original XSD source as a stream.
public boolean
isNamespaceDefined(String namespace)
True if the typeloader contains any definitions in the given namespace.
public XmlObject
newInstance(SchemaType type, XmlOptions options)
Creates an instance of the given type.
public XMLInputStream
newValidatingXMLInputStream(XMLInputStream xis, SchemaType type, XmlOptions options)
Returns a validating XMLInputStream that will throw an exception if the XML is not valid
public XmlSaxHandler
newXmlSaxHandler(SchemaType type, XmlOptions options)
Returns an XmlSaxHandler that can parse an instance of the given type.
public XmlObject
parse(String xmlText, SchemaType type, XmlOptions options)
Parses an instance of the given type.
public XmlObject
parse(File file, SchemaType type, XmlOptions options)
Parses an instance of the given type.
public XmlObject
parse(URL file, SchemaType type, XmlOptions options)
Parses an instance of the given type.
public XmlObject
parse(InputStream jiois, SchemaType type, XmlOptions options)
Parses an instance of the given type.
public XmlObject
parse(Reader jior, SchemaType type, XmlOptions options)
Parses an instance of the given type.
public XmlObject
parse(Node node, SchemaType type, XmlOptions options)
Parses an instance of the given type.
public XmlObject
parse(XMLInputStream xis, SchemaType type, XmlOptions options)
Parses an instance of the given type.
public SchemaType
typeForClassname(String classname)
Finds a type for a given fully-qualified XML Bean classname
public SchemaType
typeForSignature(String signature)
Finds a type for a given signature string

Method Detail

compilePath(String, XmlOptions) Method

public String compilePath(String pathExpr, 
                          XmlOptions options)
throws XmlException
Compiles an XPath

Exceptions

XmlException

compileQuery(String, XmlOptions) Method

public String compileQuery(String queryExpr, 
                           XmlOptions options)
throws XmlException
Compiles an XQuery

Exceptions

XmlException

findAttribute(QName) Method

public SchemaGlobalAttribute findAttribute(QName name)
Returns the global attribute defintion with the given name, or null if none.


findAttributeGroup(QName) Method

public SchemaAttributeGroup findAttributeGroup(QName name)
Returns the attribute group defintion with the given name, or null if none.


findAttributeGroupRef(QName) Method

public SchemaAttributeGroup.Ref findAttributeGroupRef(QName name)
Used for on-demand loading.


findAttributeRef(QName) Method

public SchemaGlobalAttribute.Ref findAttributeRef(QName name)
Used for on-demand loading.


findAttributeType(QName) Method

public SchemaType findAttributeType(QName name)
Returns the attribute type containing the given attribute name, or null if none.


findAttributeTypeRef(QName) Method

public SchemaType.Ref findAttributeTypeRef(QName name)
Used for on-demand loading.


findDocumentType(QName) Method

public SchemaType findDocumentType(QName name)
Returns the document type rooted at the given element name, or null if none.


findDocumentTypeRef(QName) Method

public SchemaType.Ref findDocumentTypeRef(QName name)
Used for on-demand loading.


findElement(QName) Method

public SchemaGlobalElement findElement(QName name)
Returns the global element defintion with the given name, or null if none.


findElementRef(QName) Method

public SchemaGlobalElement.Ref findElementRef(QName name)
Used for on-demand loading.


findIdentityConstraintRef(QName) Method

public SchemaIdentityConstraint.Ref findIdentityConstraintRef(QName name)
Used for on-demand loading.


findModelGroup(QName) Method

public SchemaModelGroup findModelGroup(QName name)
Returns the model group defintion with the given name, or null if none.


findModelGroupRef(QName) Method

public SchemaModelGroup.Ref findModelGroupRef(QName name)
Used for on-demand loading.


findType(QName) Method

public SchemaType findType(QName name)
Returns the type with the given name, or null if none.


findTypeRef(QName) Method

public SchemaType.Ref findTypeRef(QName name)
Used for on-demand loading.


getSourceAsStream(String) Method

public InputStream getSourceAsStream(String sourceName)
Loads original XSD source as a stream. See SchemaType.getSourceName().


isNamespaceDefined(String) Method

public boolean isNamespaceDefined(String namespace)
True if the typeloader contains any definitions in the given namespace.


newInstance(SchemaType, XmlOptions) Method

public XmlObject newInstance(SchemaType type, 
                             XmlOptions options)
Creates an instance of the given type.


newValidatingXMLInputStream(XMLInputStream, SchemaType, XmlOptions) Method

DEPRECATED Superceded by JSR 173

public XMLInputStream newValidatingXMLInputStream(XMLInputStream xis, 
                                                  SchemaType type, 
                                                  XmlOptions options)
throws XmlException, XMLStreamException
Returns a validating XMLInputStream that will throw an exception if the XML is not valid

Exceptions

XmlException
XMLStreamException

newXmlSaxHandler(SchemaType, XmlOptions) Method

public XmlSaxHandler newXmlSaxHandler(SchemaType type, 
                                      XmlOptions options)
Returns an XmlSaxHandler that can parse an instance of the given type.


parse(String, SchemaType, XmlOptions) Method

public XmlObject parse(String xmlText, 
                       SchemaType type, 
                       XmlOptions options)
throws XmlException
Parses an instance of the given type.

Exceptions

XmlException

parse(File, SchemaType, XmlOptions) Method

public XmlObject parse(File file, 
                       SchemaType type, 
                       XmlOptions options)
throws XmlException, IOException
Parses an instance of the given type.

Exceptions

XmlException
IOException

parse(URL, SchemaType, XmlOptions) Method

public XmlObject parse(URL file, 
                       SchemaType type, 
                       XmlOptions options)
throws XmlException, IOException
Parses an instance of the given type.

Exceptions

XmlException
IOException

parse(InputStream, SchemaType, XmlOptions) Method

public XmlObject parse(InputStream jiois, 
                       SchemaType type, 
                       XmlOptions options)
throws XmlException, IOException
Parses an instance of the given type.

Exceptions

XmlException
IOException

parse(Reader, SchemaType, XmlOptions) Method

public XmlObject parse(Reader jior, 
                       SchemaType type, 
                       XmlOptions options)
throws XmlException, IOException
Parses an instance of the given type.

Exceptions

XmlException
IOException

parse(Node, SchemaType, XmlOptions) Method

public XmlObject parse(Node node, 
                       SchemaType type, 
                       XmlOptions options)
throws XmlException
Parses an instance of the given type.

Exceptions

XmlException

parse(XMLInputStream, SchemaType, XmlOptions) Method

DEPRECATED Superceded by JSR 173

public XmlObject parse(XMLInputStream xis, 
                       SchemaType type, 
                       XmlOptions options)
throws XmlException, XMLStreamException
Parses an instance of the given type.

Exceptions

XmlException
XMLStreamException

typeForClassname(String) Method

public SchemaType typeForClassname(String classname)
Finds a type for a given fully-qualified XML Bean classname


typeForSignature(String) Method

public SchemaType typeForSignature(String signature)
Finds a type for a given signature string