Package org.apache.ws.commons.schema
Class XmlSchemaCollection
java.lang.Object
org.apache.ws.commons.schema.XmlSchemaCollection
Contains a cache of XML Schema definition language (XSD).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classKey that identifies a schema in a collection, composed of a targetNamespace and a system ID. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) Stringbase URI is used as the base for loading the importsprivate ExtensionRegistryThis map contains a list of Schema objects keyed in by their namespaces.private NamespacePrefixListIn-scope namespaces for XML processingprivate URIResolverResolver to find included schemas.private Map<XmlSchemaCollection.SchemaKey, XmlSchema> Map of included schemas.(package private) Deque<XmlSchemaCollection.SchemaKey> stack to track imports (to prevent recursion)(package private) Map<QName, List<TypeReceiver>> (package private) XmlSchema -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidaddSchema(XmlSchemaCollection.SchemaKey pKey, XmlSchema pSchema) private voidaddSimpleType(XmlSchema schema, String typeName) (package private) voidaddUnresolvedType(QName type, TypeReceiver receiver) booleanReturn an indication of whether a particular schema is not in the working stack of schemas.(package private) booleangetAttributeByQName(QName schemaAttributeName) Find a global attribute by QName in this collection of schemas.getElementByQName(QName qname) Retrieve a global element from the schema collection.getGroupByQName(QName name) get the namespace map(package private) XmlSchemagetKnownSchema(String namespace) gets a schema from the external namespace mapRetrieve the namespace context.getNotationByQName(QName name) (package private) XmlSchemaGet a schema given a SchemaKeyRetrieve the custom URI resolver, if any.private StringgetTypeByQName(QName schemaTypeName) Retrieve a global type from the schema collection.getXmlSchema(String systemId) Retrieve a set containing the XmlSchema instances with the given system ID.Returns an array of all the XmlSchemas in this collection.voidinit()This section should comply to the XMLSchema specification; see http://www.w3.org/TR/2004/PER-xmlschema-2-20040318/datatypes.html#built-in-datatypes.private DocumentparseDoPriv(InputSource inputSource, DocumentBuilder builder, Document doc) voidpop()Pop the stack of schemas.voidPush a schema onto the stack of schemas.Read an XML schema into the collection from a TRaX source.Read an XML schema into the collection from a DOM document.Read an XML Schema from a complete XSD XML DOM Document into this collection.read(Document doc, String systemId, TargetNamespaceValidator validator) Read an XML Schema from a complete XSD XML DOM Document into this collection.Read an XML Schema into the collection from a DOM element.Read a schema from a DOM tree into the collection.read(InputSource inputSource) Read an XML schema into the collection from a SAX InputSource.(package private) XmlSchemaread(InputSource inputSource, TargetNamespaceValidator namespaceValidator) (package private) voidresolveType(QName typeName, XmlSchemaType type) schemaForNamespace(String uri) Return the schema from this collection for a particular targetNamespace.voidsetBaseUri(String baseUri) Set the base URI.private voidsetDerivationByList(XmlSchema xsd, QName child, QName parent) private voidsetDerivationByRestriction(XmlSchema xsd, QName child, QName parent) private voidsetDerivationByRestriction(XmlSchema xsd, QName child, QName parent, XmlSchemaFacet[] facets) voidsetExtReg(ExtensionRegistry extReg) voidsetKnownNamespaceMap(Map<String, XmlSchema> knownNamespaceMap) sets the known namespace mapvoidsetNamespaceContext(NamespacePrefixList namespaceContext) Set the namespace context for this collection, which controls the assignment of namespace prefixes to namespaces.voidsetSchemaResolver(URIResolver schemaResolver) Register a custom URI resolverprivate voidtoString()
-
Field Details
-
baseUri
String baseUribase URI is used as the base for loading the imports -
stack
stack to track imports (to prevent recursion) -
unresolvedTypes
Map<QName,List<TypeReceiver>> unresolvedTypes -
xsd
XmlSchema xsd -
extReg
-
knownNamespaceMap
This map contains a list of Schema objects keyed in by their namespaces. When resolving schemas, this map will be checked for the presence of the schema first. -
namespaceContext
In-scope namespaces for XML processing -
schemaResolver
Resolver to find included schemas. -
schemas
Map of included schemas.
-
-
Constructor Details
-
XmlSchemaCollection
public XmlSchemaCollection()Creates new XmlSchemaCollection
-
-
Method Details
-
check
Return an indication of whether a particular schema is not in the working stack of schemas. This function, while public, is probably not useful outside of the implementation.- Parameters:
pKey- schema key- Returns:
- false if the schema is in the stack.
-
getExtReg
-
getKnownNamespaceMap
get the namespace map- Returns:
- a map of previously known XMLSchema objects keyed by their namespace (String)
-
getNamespaceContext
Retrieve the namespace context.- Returns:
- the namespace context.
-
getSchemaResolver
Retrieve the custom URI resolver, if any.- Returns:
- the current resolver.
-
getTypeByQName
Retrieve a global type from the schema collection.- Parameters:
schemaTypeName- the QName of the type.- Returns:
- the type object, or null.
-
getXmlSchema
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
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 -
getSystemProperty
-
setupBuiltinDatatypeHierarchy
-
setDerivationByRestriction
-
setDerivationByRestriction
private void setDerivationByRestriction(XmlSchema xsd, QName child, QName parent, XmlSchemaFacet[] facets) -
setDerivationByList
-
pop
public void pop()Pop the stack of schemas. This function, while public, is probably not useful outside of the implementation. -
push
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
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
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
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.- Returns:
- the XML schema object.
-
read
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
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
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
-
read
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.- Returns:
- the XML schema object.
-
schemaForNamespace
Return the schema from this collection for a particular targetNamespace.- Parameters:
uri- target namespace URI.- Returns:
- the schema.
-
setBaseUri
Set the base URI. This is used when schemas need to be loaded from relative locations- Parameters:
baseUri- baseUri for this collection.
-
setExtReg
-
setKnownNamespaceMap
sets the known namespace map- Parameters:
knownNamespaceMap- a map of previously known XMLSchema objects keyed by their namespace (String)
-
setNamespaceContext
Set the namespace context for this collection, which controls the assignment of namespace prefixes to namespaces.- Parameters:
namespaceContext- the context.
-
setSchemaResolver
Register a custom URI resolver- Parameters:
schemaResolver- resolver
-
toString
-
addSchema
-
addUnresolvedType
-
containsSchema
-
getKnownSchema
gets a schema from the external namespace map- Parameters:
namespace-- Returns:
-
getSchema
Get a schema given a SchemaKey- Parameters:
pKey-- Returns:
-
read
-
resolveType
-
addSimpleType
-
parseDoPriv
private Document parseDoPriv(InputSource inputSource, DocumentBuilder builder, Document doc) throws IOException, SAXException - Throws:
IOExceptionSAXException
-
getAttributeByQName
Find a global attribute by QName in this collection of schemas.- Parameters:
schemaAttributeName- the name of the attribute.- Returns:
- the attribute or null.
-
getElementByQName
Retrieve a global element from the schema collection.- Parameters:
qname- the element QName.- Returns:
- the element object, or null.
-
getAttributeGroupByQName
-
getGroupByQName
-
getNotationByQName
-