Free Trial - Stylus Studio, The World's Best XML IDE!


com.saxonica.schema
Class Schema

java.lang.Object
  |
  +--com.saxonica.schema.SchemaElement
        |
        +--com.saxonica.schema.Schema
All Implemented Interfaces:
SchemaMarker, java.io.Serializable, javax.xml.transform.SourceLocator

public class Schema
extends SchemaElement
implements SchemaMarker

A class representing a collection of schema components corresponding to a single target namespaces. In other words, the contents of a schema document together with the schema documents it references using xs:include.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.saxonica.schema.SchemaElement
ANNOTATION, ANYTYPE, APPINFO, ATTRIBUTE, ATTRIBUTE_GROUP, COMPLEX_CONTENT, COMPLEX_TYPE, COMPOSITOR, DOCUMENTATION, ELEMENT, FACET, GROUP, IDENTITY_FIELD, IDENTITY_SELECTOR, KEY, KEYREF, LIST, REDEFINE, SCHEMA, SIMPLE_CONTENT, SIMPLE_TYPE, UNION, UNIQUE, UNKNOWN, WILDCARD_ATTRIBUTE, WILDCARD_ELEMENT
 
Constructor Summary
Schema(NamePool pool, SchemaAwareConfiguration config)
          Create a new Schema definition
 
Method Summary
 void addAttribute(AttributeDecl attribute)
          Adds the given attribute definition to this Schema.
 void addComplexType(UserComplexType complexType)
          Adds the given Complextype definition to this Schema defintion.
 void addComponent(SchemaComponent obj)
          Add an object that might contain a forwards reference to be fixed up later
 void addElementDecl(ElementDecl elementDecl)
          Adds the given Element declaration to this Schema defintion
 void addIdentityConstraint(IdentityConstraint constraint)
          Add an identity constraint
 void addImportedSchema(Schema schema)
          Adds the given Schema definition to this Schema definition as an imported schenma
 void addSimpleType(SimpleTypeDefinition simpleType)
          Adds the given named SimpleType definition to this Schema.
 void copyTo(Schema destination)
          Copy the contents of this schema to another schema
 void error(java.lang.String message, javax.xml.transform.SourceLocator locator)
          Report an error
 void fixupForwardsReferences(javax.xml.transform.ErrorListener listener)
          Fix up references and check for circularities
 java.lang.String getAttributeFormDefault()
          Returns the attributeFormDefault property of this Schema.
 int getBlockDefault()
          Returns the default BlockList for this Schema.
 UserComplexType getComplexType(java.lang.String localName)
          Get the top-level complex type within this schema that has a given local name.
 SchemaAwareConfiguration getConfiguration()
          Get the configuration
 ElementDecl getElementDeclaration(java.lang.String localName)
          Get the element declaration with a given local name
 java.lang.String getElementFormDefault()
          Returns the elementFormDefault property of this Schema.
 int getErrorCount()
          Test whether errors have been reported
 int getFinalDefault()
          Returns the default FinalList for this Schema.
 java.lang.String getId()
          Returns the Id for this Schema, as specified by the Id attribute, or null if no Id exists.
 IdentityConstraint getIdentityConstraint(int fingerprint)
          Get the identity constraint whose name has a given fingerprint
 Schema getImportedSchema(java.lang.String ns)
          Returns an imported schema by its namespace
 NamePool getNamePool()
          Get the NamePool used by this schema
 java.lang.String getSchemaLocation()
          Returns the schemaLocation hint provided for this schema
 SimpleTypeDefinition getSimpleType(int fingerprint)
          Get the top-level simple type within this schema that has a given fingerprint.
 short getStructureType()
          Returns the type of this Schema Structure
 SuperSchema getSuperSchema()
          Get the SuperSchema holding indexes of names defined in any schema
 java.lang.String getTargetNamespace()
          Returns the target namespace for this Schema, or "" if no namespace has been defined.
 java.lang.String getVersion()
          Returns the version information of the XML Schema definition represented by this Schema instance.
 void registerId(java.lang.String id, java.lang.Object object, javax.xml.transform.SourceLocator locator)
          Register an ID; throw an exception if it is not unique
 void registerSchemaType(SchemaType type)
          Register a top-level SchemaType (simple type or complex type) in the NamePool, using its fingerprint
 void rollback()
          After an error, remove all the global schema components from the namepool
 void setAttributeFormDefault(java.lang.String attributeFormDefault)
          Sets the attributeFormDefault property of this Schema.
 void setBlockDefault(int value)
          Sets the default Block values for this Schema.
 void setConfiguration(SchemaAwareConfiguration config)
          Set the configuration
 void setElementFormDefault(java.lang.String elementFormDefault)
          Sets the elementFormDefault property of this Schema.
 void setFinalDefault(int value)
          Sets the default "final" list for this Schema.
 void setId(java.lang.String id)
          Sets the Id for this Schema
 void setSchemaLocation(java.lang.String schemaLocation)
          Set the schemaLocation for this schema.
 void setTargetNamespace(java.lang.String targetNamespace)
          Sets the target namespace for this Schema
 void setVersion(java.lang.String version)
          Sets the version information for the XML Schema defintion represented by this Schema instance.
 boolean validate(javax.xml.transform.ErrorListener errorListener)
          Checks the validity of this Schema definition.
 
Methods inherited from class com.saxonica.schema.SchemaElement
getColumnNumber, getLineNumber, getPublicId, getSystemId, setLocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Schema

public Schema(NamePool pool,
              SchemaAwareConfiguration config)
Create a new Schema definition

Parameters:
pool - A NamePool used to hold the names defined in this schema
config - The configuration object holding system configuration information
Method Detail

getSuperSchema

public SuperSchema getSuperSchema()
Get the SuperSchema holding indexes of names defined in any schema


setConfiguration

public void setConfiguration(SchemaAwareConfiguration config)
Set the configuration


getConfiguration

public SchemaAwareConfiguration getConfiguration()
Get the configuration


addComponent

public void addComponent(SchemaComponent obj)
Add an object that might contain a forwards reference to be fixed up later


fixupForwardsReferences

public void fixupForwardsReferences(javax.xml.transform.ErrorListener listener)
                             throws javax.xml.transform.TransformerException
Fix up references and check for circularities

javax.xml.transform.TransformerException

registerId

public void registerId(java.lang.String id,
                       java.lang.Object object,
                       javax.xml.transform.SourceLocator locator)
                throws SchemaException
Register an ID; throw an exception if it is not unique

SchemaException

addAttribute

public void addAttribute(AttributeDecl attribute)
Adds the given attribute definition to this Schema. It will overwrite any existing attribute declaration with the same name.

Parameters:
attribute - the AttributeDecl to add

addComplexType

public void addComplexType(UserComplexType complexType)
                    throws SchemaException
Adds the given Complextype definition to this Schema defintion. If another complex type with this name already exists, it is overwritten.

Parameters:
complexType - the Complextype to add to this Schema
Throws:
SchemaException - if the Complextype does not have a name

getComplexType

public UserComplexType getComplexType(java.lang.String localName)
Get the top-level complex type within this schema that has a given local name.

Returns:
the UserComplexType, or null if there is none with this name

getSimpleType

public SimpleTypeDefinition getSimpleType(int fingerprint)
Get the top-level simple type within this schema that has a given fingerprint. Available only during schema construction; after that, use the NamePool

Returns:
the SimpleTypeDefinition, or null if there is none with this name

addElementDecl

public void addElementDecl(ElementDecl elementDecl)
                    throws SchemaException
Adds the given Element declaration to this Schema defintion

Parameters:
elementDecl - the ElementDecl to add to this SchemaDef
Throws:
SchemaException - when an ElementDecl already exists with the same name as the given ElementDecl

getElementDeclaration

public ElementDecl getElementDeclaration(java.lang.String localName)
Get the element declaration with a given local name

Parameters:
localName - the local name of the element
Returns:
the element declaration, or null if not found.

addImportedSchema

public void addImportedSchema(Schema schema)
                       throws SchemaException
Adds the given Schema definition to this Schema definition as an imported schenma

Parameters:
schema - the Schema to add to this Schema as an imported schema
Throws:
SchemaException - if the Schema already exists

addSimpleType

public void addSimpleType(SimpleTypeDefinition simpleType)
                   throws SchemaException
Adds the given named SimpleType definition to this Schema. If another simpleType with the same name already exists, it is overwritten.

Parameters:
simpleType - the SimpleType to add to this Schema
Throws:
SchemaException - if the SimpleType does not have a name

registerSchemaType

public void registerSchemaType(SchemaType type)
Register a top-level SchemaType (simple type or complex type) in the NamePool, using its fingerprint

Parameters:
type - The type to be registered

getNamePool

public NamePool getNamePool()
Get the NamePool used by this schema


getAttributeFormDefault

public java.lang.String getAttributeFormDefault()
Returns the attributeFormDefault property of this Schema.

Returns:
the attributeFormDefault property of this Schema, or null if no default Form was set. If no default Form has been set, the user should assume Form.Unqualified. The value is returned as a string, "qualified" or "unqualified".

getBlockDefault

public int getBlockDefault()
Returns the default BlockList for this Schema.

Returns:
the default BlockList for this Schema, as an integer with bit-significant fields

getElementFormDefault

public java.lang.String getElementFormDefault()
Returns the elementFormDefault property of this Schema.

Returns:
the elementFormDefault property of this Schema. The value is returned as a string ("qualified" or "unqualified"), or null if no default Form was set. If no default Form has been set, the user should assume "unqualified".

getFinalDefault

public int getFinalDefault()
Returns the default FinalList for this Schema.

Returns:
final the default FinalList for this Schema.

getSchemaLocation

public java.lang.String getSchemaLocation()
Returns the schemaLocation hint provided for this schema

Returns:
the schemaLocation hint provided for this schema

addIdentityConstraint

public void addIdentityConstraint(IdentityConstraint constraint)
Add an identity constraint


getIdentityConstraint

public IdentityConstraint getIdentityConstraint(int fingerprint)
Get the identity constraint whose name has a given fingerprint

Returns:
the identity constraint, or null if there is none with that name

getId

public java.lang.String getId()
Returns the Id for this Schema, as specified by the Id attribute, or null if no Id exists.

Returns:
the Id for this Scheam, or null if no Id exists

getImportedSchema

public Schema getImportedSchema(java.lang.String ns)
Returns an imported schema by its namespace

Returns:
The imported schema

getTargetNamespace

public java.lang.String getTargetNamespace()
Returns the target namespace for this Schema, or "" if no namespace has been defined.

Returns:
the target namespace for this Schema, or "" if no namespace has been defined

getVersion

public java.lang.String getVersion()
Returns the version information of the XML Schema definition represented by this Schema instance.

Returns:
the version information of the XML Schema definition, or null if no version information exists.

setAttributeFormDefault

public void setAttributeFormDefault(java.lang.String attributeFormDefault)
Sets the attributeFormDefault property of this Schema.

Parameters:
attributeFormDefault - the Form value of the attributeFormDefault property for this Schema, as a string, "qualified" or "unqualified". The caller is responsible for validating the value.

setBlockDefault

public void setBlockDefault(int value)
Sets the default Block values for this Schema.

Parameters:
value - the default Block values to set for this Schema, as a bit-significant integer.

setElementFormDefault

public void setElementFormDefault(java.lang.String elementFormDefault)
Sets the elementFormDefault property of this Schema.

Parameters:
elementFormDefault - the Form value of the elementFormDefault property for this Schema.

setFinalDefault

public void setFinalDefault(int value)
Sets the default "final" list for this Schema.

Parameters:
value - the default final values to set for this Schema, as a bit-significant integer

setSchemaLocation

public void setSchemaLocation(java.lang.String schemaLocation)
Set the schemaLocation for this schema. This is useful when this schema has been imported by another schema

Parameters:
schemaLocation - the location hint for this Schema

setId

public void setId(java.lang.String id)
Sets the Id for this Schema

Parameters:
id - the Id for this Schema

setTargetNamespace

public void setTargetNamespace(java.lang.String targetNamespace)
Sets the target namespace for this Schema

Parameters:
targetNamespace - the target namespace for this Schema
See Also:
§ 2.7 XML Schema Part 1: Structures

setVersion

public void setVersion(java.lang.String version)
Sets the version information for the XML Schema defintion represented by this Schema instance.

Parameters:
version - the version for this XML Schema defination.

copyTo

public void copyTo(Schema destination)
            throws SchemaException
Copy the contents of this schema to another schema

Parameters:
destination - the destination of the copy
Throws:
SchemaException - if there are name clashes between this schema and the destination schema

getStructureType

public short getStructureType()
Returns the type of this Schema Structure

Specified by:
getStructureType in class SchemaElement
Returns:
the type of this Schema Structure

validate

public boolean validate(javax.xml.transform.ErrorListener errorListener)
                 throws javax.xml.transform.TransformerException
Checks the validity of this Schema definition.

Parameters:
errorListener - an error handler to which all errors should be reported
Throws:
javax.xml.transform.TransformerException - if the ErrorListener decides that an error is fatal

getErrorCount

public int getErrorCount()
Test whether errors have been reported


error

public void error(java.lang.String message,
                  javax.xml.transform.SourceLocator locator)
           throws SchemaException
Report an error

Specified by:
error in interface SchemaMarker
SchemaException

rollback

public void rollback()
After an error, remove all the global schema components from the namepool



Stylus Studio features integrated development and debugging support for Saxon in the XQuery editor and XSLT editor.