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(QName schemaAttributeName)
          Find a global attribute by QName in this collection of schemas.
 XmlSchemaAttributeGroup getAttributeGroupByQName(QName name)
           
 XmlSchemaElement getElementByQName(QName qname)
          Retrieve a global element from the schema collection.
 ExtensionRegistry getExtReg()
           
 XmlSchemaGroup getGroupByQName(QName name)
           
 Map<String,XmlSchema> getKnownNamespaceMap()
          get the namespace map
 NamespacePrefixList getNamespaceContext()
          Retrieve the namespace context.
 XmlSchemaNotation getNotationByQName(QName name)
           
 URIResolver getSchemaResolver()
          Retrieve the custom URI resolver, if any.
 XmlSchemaType getTypeByQName(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(Document doc)
          Read an XML schema into the collection from a DOM document.
 XmlSchema read(Document doc, String systemId)
          Read an XML Schema from a complete XSD XML DOM Document into this collection.
 XmlSchema read(Document doc, String systemId, TargetNamespaceValidator validator)
          Read an XML Schema from a complete XSD XML DOM Document into this collection.
 XmlSchema read(Element elem)
          Read an XML Schema into the collection from a DOM element.
 XmlSchema read(Element elem, String systemId)
          Read a schema from a DOM tree into the collection.
 XmlSchema read(InputSource inputSource)
          Read an XML schema into the collection from a SAX InputSource.
 XmlSchema read(Reader r)
           
 XmlSchema read(Source source)
          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 setExtReg(ExtensionRegistry extReg)
           
 void setKnownNamespaceMap(Map<String,XmlSchema> 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

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.

getExtReg

public ExtensionRegistry getExtReg()

getKnownNamespaceMap

public Map<String,XmlSchema> getKnownNamespaceMap()
get the namespace map

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

getNamespaceContext

public NamespacePrefixList getNamespaceContext()
Retrieve the namespace context.

Returns:
the namespace context.

getSchemaResolver

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

Returns:
the current resolver.

getTypeByQName

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

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

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

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


pop

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


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.

read

public XmlSchema read(Document doc,
                      String systemId)
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.
Returns:
the schema object.

read

public XmlSchema read(Document doc,
                      String systemId,
                      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.
validator - object that is called back to check validity of the target namespace.
Returns:
the schema object.

read

public XmlSchema read(Document doc)
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(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(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.

read

public XmlSchema read(InputSource inputSource)
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.
Returns:
the XML schema object.

read

public XmlSchema read(Reader r)

read

public XmlSchema read(Source source)
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.

schemaForNamespace

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

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

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.

setExtReg

public void setExtReg(ExtensionRegistry extReg)

setKnownNamespaceMap

public void setKnownNamespaceMap(Map<String,XmlSchema> knownNamespaceMap)
sets the known namespace map

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

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.

setSchemaResolver

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

Parameters:
schemaResolver - resolver

toString

public String toString()
Overrides:
toString in class Object

getAttributeByQName

public XmlSchemaAttribute getAttributeByQName(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.

getElementByQName

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

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

getAttributeGroupByQName

public XmlSchemaAttributeGroup getAttributeGroupByQName(QName name)

getGroupByQName

public XmlSchemaGroup getGroupByQName(QName name)

getNotationByQName

public XmlSchemaNotation getNotationByQName(QName name)


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