org.deegree.commons.xml.schema
Class XMLSchemaInfoSet

java.lang.Object
  extended by org.deegree.commons.xml.schema.XMLSchemaInfoSet
Direct Known Subclasses:
GMLSchemaInfoSet

public class XMLSchemaInfoSet
extends java.lang.Object

Provides convenient methods to retrieve "relevant" element and type declarations of an XML schema infoset.

This functionality is very handy for extracting higher-level structures defined using XML schema, such as GML feature types.

Version:
$Revision:$, $Date:$
Author:
Markus Schneider , last edited by: $Author:$
See Also:
GMLSchemaInfoSet

Field Summary
protected  org.apache.xerces.xs.XSModel xmlSchema
          The XML schema infoset.
 
Constructor Summary
XMLSchemaInfoSet(java.lang.String... schemaUrls)
          Creates a new XMLSchemaInfoSet instance that reads the schema documents from the given URLs.
XMLSchemaInfoSet(org.apache.xerces.xs.XSModel xmlSchema)
          Creates a new XSModelAnalyzer for the given (Xerces) XML schema infoset.
 
Method Summary
 java.util.List<java.lang.String> getComponentLocations(java.lang.String namespace)
          Returns the locations of all schema files that contributed to the given namespace.
 java.util.Map<java.lang.String,java.lang.String> getNamespacePrefixes()
          Returns the prefix to namespace bindings used in the original XML schema documents.
 org.apache.xerces.xs.XSNamespaceItemList getNamespaces()
           
 java.util.Set<java.lang.String> getSchemaNamespaces()
          Returns all namespaces that participate in this infoset.
 java.util.List<org.apache.xerces.xs.XSElementDeclaration> getSubstitutions(javax.xml.namespace.QName elementName, java.lang.String namespace, boolean transitive, boolean onlyConcrete)
          Returns the declarations of all elements that are substitutable for a given element name.
 java.util.List<org.apache.xerces.xs.XSElementDeclaration> getSubstitutions(org.apache.xerces.xs.XSElementDeclaration elementDecl, java.lang.String namespace, boolean transitive, boolean onlyConcrete)
          Returns the declarations of all elements that are substitutable for a given element declaration.
 java.util.List<org.apache.xerces.xs.XSTypeDefinition> getSubtypes(org.apache.xerces.xs.XSTypeDefinition typeDef, java.lang.String namespace, boolean transitive, boolean onlyConcrete)
          Returns the subtypes for the given type definition.
 org.apache.xerces.xs.XSModel getXSModel()
          Returns the XML schema infoset (represented as a Xerces XSModel).
static org.apache.xerces.xs.XSModel loadModel(java.lang.String... schemaUrls)
          Creates a Xerces XSModel from the schemas at the given URLs, using the RedirectingEntityResolver, so OGC schemas URLs are redirected to a local copy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlSchema

protected final org.apache.xerces.xs.XSModel xmlSchema
The XML schema infoset.

Constructor Detail

XMLSchemaInfoSet

public XMLSchemaInfoSet(org.apache.xerces.xs.XSModel xmlSchema)
Creates a new XSModelAnalyzer for the given (Xerces) XML schema infoset.

Parameters:
xmlSchema - schema infoset, must not be null

XMLSchemaInfoSet

public XMLSchemaInfoSet(java.lang.String... schemaUrls)
                 throws java.lang.ClassCastException,
                        java.lang.ClassNotFoundException,
                        java.lang.InstantiationException,
                        java.lang.IllegalAccessException
Creates a new XMLSchemaInfoSet instance that reads the schema documents from the given URLs.

Parameters:
schemaUrls - locations of the schema documents, must not be null and contain at least one entry
Throws:
java.lang.ClassCastException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
Method Detail

getSchemaNamespaces

public java.util.Set<java.lang.String> getSchemaNamespaces()
Returns all namespaces that participate in this infoset.

Returns:
all namespaces, never null

getNamespacePrefixes

public java.util.Map<java.lang.String,java.lang.String> getNamespacePrefixes()
Returns the prefix to namespace bindings used in the original XML schema documents.

Returns:
the prefix to namespace bindings, never null (but does not necessarily bindings for all namespaces)

getComponentLocations

public java.util.List<java.lang.String> getComponentLocations(java.lang.String namespace)
Returns the locations of all schema files that contributed to the given namespace.

Parameters:
namespace - namespace, must not be null
Returns:
the locations of the schema files, or null if the namespace does not belong to the schema

getNamespaces

public org.apache.xerces.xs.XSNamespaceItemList getNamespaces()
Returns:

getXSModel

public org.apache.xerces.xs.XSModel getXSModel()
Returns the XML schema infoset (represented as a Xerces XSModel).

Returns:
the XML schema infoset

getSubstitutions

public java.util.List<org.apache.xerces.xs.XSElementDeclaration> getSubstitutions(org.apache.xerces.xs.XSElementDeclaration elementDecl,
                                                                                  java.lang.String namespace,
                                                                                  boolean transitive,
                                                                                  boolean onlyConcrete)
Returns the declarations of all elements that are substitutable for a given element declaration.

Parameters:
elementDecl - element declaration, must not be null
namespace - only element declarations in this namespace are returned, set to null for all namespaces
transitive - if true, also substitutions for substitutions (and so on) are included
onlyConcrete - if true, only concrete (non-abstract) declarations are returned
Returns:
the declarations of all substitution elements in the requested namespace

getSubtypes

public java.util.List<org.apache.xerces.xs.XSTypeDefinition> getSubtypes(org.apache.xerces.xs.XSTypeDefinition typeDef,
                                                                         java.lang.String namespace,
                                                                         boolean transitive,
                                                                         boolean onlyConcrete)
Returns the subtypes for the given type definition.

Parameters:
typeDef - type definition, must not be null
namespace - only type definitions in this namespace are returned, set to null for all namespaces
transitive - if true, also subtypes of subtypes (and so on) are included
onlyConcrete - if true, only concrete (non-abstract) definitions are returned
Returns:
the definition of all sub type definitions in the requested namespace

getSubstitutions

public java.util.List<org.apache.xerces.xs.XSElementDeclaration> getSubstitutions(javax.xml.namespace.QName elementName,
                                                                                  java.lang.String namespace,
                                                                                  boolean transitive,
                                                                                  boolean onlyConcrete)
Returns the declarations of all elements that are substitutable for a given element name.

Parameters:
elementName - qualified name of the element, must not be null
namespace - only element declarations in this namespace are returned, set to null for all namespaces
transitive - if true, also substitutions for substitutions (and so one) are included
onlyConcrete - if true, only concrete (non-abstract) declarations are returned
Returns:
the declarations of all substitution elements in the requested namespace

loadModel

public static org.apache.xerces.xs.XSModel loadModel(java.lang.String... schemaUrls)
                                              throws java.lang.ClassCastException,
                                                     java.lang.ClassNotFoundException,
                                                     java.lang.InstantiationException,
                                                     java.lang.IllegalAccessException
Creates a Xerces XSModel from the schemas at the given URLs, using the RedirectingEntityResolver, so OGC schemas URLs are redirected to a local copy.

Parameters:
schemaUrls - locations of the schema documents, must not be null and contain at least one entry
Returns:
the XML schema infoset, never null
Throws:
java.lang.ClassCastException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException


Copyright © 2011. All Rights Reserved.