org.apache.ws.commons.schema
Class XmlSchemaCollection

java.lang.Object
  extended by org.apache.ws.commons.schema.XmlSchemaCollection

public final class XmlSchemaCollection
extends Object

Contains a cache of XML Schema definition language (XSD).


Nested Class Summary
static class XmlSchemaCollection.SchemaKey
          Key that identifies a schema in a collection, composed of a targetNamespace and a system ID.
 
Constructor Summary
XmlSchemaCollection()
          Creates new XmlSchemaCollection
 
Method Summary
 boolean check(XmlSchemaCollection.SchemaKey pKey)
          Return an indication of whether a particular schema is in the working stack of schemas.
 XmlSchemaAttribute getAttributeByQName(javax.xml.namespace.QName schemaAttributeName)
          Find a global attribute by QName in this collection of schemas.
 XmlSchemaElement getElementByQName(javax.xml.namespace.QName qname)
          Retrieve a global element from the schema collection.
 org.xml.sax.EntityResolver getEntityResolver()
           
 ExtensionRegistry getExtReg()
           
 Map getKnownNamespaceMap()
          get the namespace map
 NamespacePrefixList getNamespaceContext()
          Retrieve the namespace context.
 URIResolver getSchemaResolver()
          Retrieve the custom URI resolver, if any.
 XmlSchemaType getTypeByQName(javax.xml.namespace.QName schemaTypeName)
          Retrieve a global type from the schema collection.
 XmlSchema[] getXmlSchema(String systemId)
          Retrieve a set containing the XmlSchema instances with the given system ID.
 XmlSchema[] getXmlSchemas()
          Returns an array of all the XmlSchemas in this collection.
 void init()
          This section should comply to the XMLSchema specification; see http://www.w3.org/TR/2004/PER-xmlschema-2-20040318/datatypes.html#built-in-datatypes.
 void pop()
          Pop the stack of schemas.
 void push(XmlSchemaCollection.SchemaKey pKey)
          Push a schema onto the stack of schemas.
 XmlSchema read(org.w3c.dom.Document doc, String systemId, ValidationEventHandler veh)
          Read an XML Schema from a complete XSD XML DOM Document into this collection.
 XmlSchema read(org.w3c.dom.Document doc, String systemId, ValidationEventHandler veh, TargetNamespaceValidator validator)
          Read an XML Schema from a complete XSD XML DOM Document into this collection.
 XmlSchema read(org.w3c.dom.Document doc, ValidationEventHandler veh)
          Read an XML schema into the collection from a DOM document.
 XmlSchema read(org.w3c.dom.Element elem)
          Read an XML Schema into the collection from a DOM element.
 XmlSchema read(org.w3c.dom.Element elem, String systemId)
          Read a schema from a DOM tree into the collection.
 XmlSchema read(org.xml.sax.InputSource inputSource, ValidationEventHandler veh)
          Read an XML schema into the collection from a SAX InputSource.
 XmlSchema read(Reader r, ValidationEventHandler veh)
           
 XmlSchema read(javax.xml.transform.Source source, ValidationEventHandler veh)
          Read an XML schema into the collection from a TRaX source.
 XmlSchema schemaForNamespace(String uri)
          Return the schema from this collection for a particular targetNamespace.
 void setBaseUri(String baseUri)
          Set the base URI.
 void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
           
 void setExtReg(ExtensionRegistry extReg)
           
 void setKnownNamespaceMap(Map knownNamespaceMap)
          sets the known namespace map
 void setNamespaceContext(NamespacePrefixList namespaceContext)
          Set the namespace context for this collection, which controls the assignment of namespace prefixes to namespaces.
 void setSchemaResolver(URIResolver schemaResolver)
          Register a custom URI resolver
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlSchemaCollection

public XmlSchemaCollection()
Creates new XmlSchemaCollection

Method Detail

getExtReg

public ExtensionRegistry getExtReg()

setExtReg

public void setExtReg(ExtensionRegistry extReg)

getKnownNamespaceMap

public Map getKnownNamespaceMap()
get the namespace map

Returns:
a map of previously known XMLSchema objects keyed by their namespace (String)

setKnownNamespaceMap

public void setKnownNamespaceMap(Map knownNamespaceMap)
sets the known namespace map

Parameters:
knownNamespaceMap - a map of previously known XMLSchema objects keyed by their namespace (String)

setBaseUri

public void setBaseUri(String baseUri)
Set the base URI. This is used when schemas need to be loaded from relative locations

Parameters:
baseUri - baseUri for this collection.

setSchemaResolver

public void setSchemaResolver(URIResolver schemaResolver)
Register a custom URI resolver

Parameters:
schemaResolver - resolver

getSchemaResolver

public URIResolver getSchemaResolver()
Retrieve the custom URI resolver, if any.

Returns:
the current resolver.

init

public void init()
This section should comply to the XMLSchema specification; see http://www.w3.org/TR/2004/PER-xmlschema-2-20040318/datatypes.html#built-in-datatypes. This needs to be inspected by another pair of eyes


read

public XmlSchema read(Reader r,
                      ValidationEventHandler veh)

read

public XmlSchema read(org.xml.sax.InputSource inputSource,
                      ValidationEventHandler veh)
Read an XML schema into the collection from a SAX InputSource. Schemas in a collection must be unique in the concatenation of system ID and targetNamespace. In this API, the systemID is taken from the source.

Parameters:
inputSource - the XSD document.
veh - handler that is called back for validation.
Returns:
the XML schema object.

read

public XmlSchema read(javax.xml.transform.Source source,
                      ValidationEventHandler veh)
Read an XML schema into the collection from a TRaX source. Schemas in a collection must be unique in the concatenation of system ID and targetNamespace. In this API, the systemID is taken from the Source.

Parameters:
source - the XSD document.
veh - handler that is called back for validation.
Returns:
the XML schema object.

read

public XmlSchema read(org.w3c.dom.Document doc,
                      ValidationEventHandler veh)
Read an XML schema into the collection from a DOM document. Schemas in a collection must be unique in the concatenation of system ID and targetNamespace. In this API, the systemID is taken from the document.

Parameters:
doc - the XSD document.
veh - handler that is called back for validation.
Returns:
the XML schema object.

read

public XmlSchema read(org.w3c.dom.Element elem)
Read an XML Schema into the collection from a DOM element. Schemas in a collection must be unique in the concatentation of System ID and targetNamespace. The system ID will be empty for this API.

Parameters:
elem - the DOM element for the schema.
Returns:
the XmlSchema

read

public XmlSchema read(org.w3c.dom.Document doc,
                      String systemId,
                      ValidationEventHandler veh)
Read an XML Schema from a complete XSD XML DOM Document into this collection. Schemas in a collection must be unique in the concatenation of SystemId and targetNamespace.

Parameters:
doc - The schema document.
systemId - System ID for this schema.
veh - handler to be called to check validity of the schema.
Returns:
the schema object.

read

public XmlSchema read(org.w3c.dom.Document doc,
                      String systemId,
                      ValidationEventHandler veh,
                      TargetNamespaceValidator validator)
Read an XML Schema from a complete XSD XML DOM Document into this collection. Schemas in a collection must be unique in the concatenation of SystemId and targetNamespace.

Parameters:
doc - Source document.
systemId - System id.
veh - Stub for future capability to handle validation errors.
validator - object that is called back to check validity of the target namespace.
Returns:
the schema object.

read

public XmlSchema read(org.w3c.dom.Element elem,
                      String systemId)
Read a schema from a DOM tree into the collection. The schemas in a collection must be unique in the concatenation of the target namespace and the system ID.

Parameters:
elem - xs:schema DOM element.
systemId - System id.
Returns:
the schema object.

getXmlSchema

public XmlSchema[] getXmlSchema(String systemId)
Retrieve a set containing the XmlSchema instances with the given system ID. In general, this will return a single instance, or none. However, if the schema has no targetNamespace attribute and was included from schemata with different target namespaces, then it may occur, that multiple schema instances with different logical target namespaces may be returned.

Parameters:
systemId - the system id for this schema
Returns:
array of XmlSchema objects

getXmlSchemas

public XmlSchema[] getXmlSchemas()
Returns an array of all the XmlSchemas in this collection.

Returns:
the list of XmlSchema objects

getElementByQName

public XmlSchemaElement getElementByQName(javax.xml.namespace.QName qname)
Retrieve a global element from the schema collection.

Parameters:
qname - the element QName.
Returns:
the element object, or null.

getTypeByQName

public XmlSchemaType getTypeByQName(javax.xml.namespace.QName schemaTypeName)
Retrieve a global type from the schema collection.

Parameters:
schemaTypeName - the QName of the type.
Returns:
the type object, or null.

getAttributeByQName

public XmlSchemaAttribute getAttributeByQName(javax.xml.namespace.QName schemaAttributeName)
Find a global attribute by QName in this collection of schemas.

Parameters:
schemaAttributeName - the name of the attribute.
Returns:
the attribute or null.

schemaForNamespace

public XmlSchema schemaForNamespace(String uri)
Return the schema from this collection for a particular targetNamespace.

Parameters:
uri - target namespace URI.
Returns:
the schema.

getNamespaceContext

public NamespacePrefixList getNamespaceContext()
Retrieve the namespace context.

Returns:
the namespace context.

setNamespaceContext

public void setNamespaceContext(NamespacePrefixList namespaceContext)
Set the namespace context for this collection, which controls the assignment of namespace prefixes to namespaces.

Parameters:
namespaceContext - the context.

push

public void push(XmlSchemaCollection.SchemaKey pKey)
Push a schema onto the stack of schemas. This function, while public, is probably not useful outside of the implementation.

Parameters:
pKey - the schema key.

pop

public void pop()
Pop the stack of schemas. This function, while public, is probably not useful outside of the implementation.


check

public boolean check(XmlSchemaCollection.SchemaKey pKey)
Return an indication of whether a particular schema is in the working stack of schemas. This function, while public, is probably not useful outside of the implementation.

Parameters:
pKey - schema key
Returns:
true if the schema is in the stack.

toString

public String toString()
Overrides:
toString in class Object

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver entityResolver)


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