Class XmlSchemaCollection

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

public final class XmlSchemaCollection extends Object
Contains a cache of XML Schema definition language (XSD).
  • Field Details

  • Constructor Details

    • XmlSchemaCollection

      public XmlSchemaCollection()
      Creates new XmlSchemaCollection
  • Method Details

    • check

      public boolean check(XmlSchemaCollection.SchemaKey pKey)
      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

      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
    • getSystemProperty

      private String getSystemProperty(String s)
    • setupBuiltinDatatypeHierarchy

      private void setupBuiltinDatatypeHierarchy(XmlSchema xsd)
    • setDerivationByRestriction

      private void setDerivationByRestriction(XmlSchema xsd, QName child, QName parent)
    • setDerivationByRestriction

      private void setDerivationByRestriction(XmlSchema xsd, QName child, QName parent, XmlSchemaFacet[] facets)
    • setDerivationByList

      private void setDerivationByList(XmlSchema xsd, QName child, QName parent)
    • 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.
      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.
      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
    • addSchema

      void addSchema(XmlSchemaCollection.SchemaKey pKey, XmlSchema pSchema)
    • addUnresolvedType

      void addUnresolvedType(QName type, TypeReceiver receiver)
    • containsSchema

      boolean containsSchema(XmlSchemaCollection.SchemaKey pKey)
    • getKnownSchema

      XmlSchema getKnownSchema(String namespace)
      gets a schema from the external namespace map
      Parameters:
      namespace -
      Returns:
    • getSchema

      Get a schema given a SchemaKey
      Parameters:
      pKey -
      Returns:
    • read

      XmlSchema read(InputSource inputSource, TargetNamespaceValidator namespaceValidator)
    • resolveType

      void resolveType(QName typeName, XmlSchemaType type)
    • addSimpleType

      private void addSimpleType(XmlSchema schema, String typeName)
    • parseDoPriv

      private Document parseDoPriv(InputSource inputSource, DocumentBuilder builder, Document doc) throws IOException, SAXException
      Throws:
      IOException
      SAXException
    • 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)