net.sf.saxon.type
Class SchemaType

java.lang.Object
  |
  +--net.sf.saxon.type.SchemaType
All Implemented Interfaces:
java.io.Serializable, javax.xml.transform.SourceLocator
Direct Known Subclasses:
AnyType, SimpleType

public abstract class SchemaType
extends java.lang.Object
implements java.io.Serializable, javax.xml.transform.SourceLocator

This class represents a simple type or complex type as defined in XML Schema. In the non-schema-aware version of Saxon it is used to represent built-in schema types only. In the schema-aware version it is subclassed to represent user-defined types.

See Also:
Serialized Form

Field Summary
static int ALL_DERIVATIONS
           
static int DERIVE_BY_EXTENSION
           
static int DERIVE_BY_LIST
           
static int DERIVE_BY_RESTRICTION
           
static int DERIVE_BY_SUBSTITUTION
           
static int DERIVE_BY_UNION
           
protected  int finalProhibitions
          Flags used to implement the "final" and "block" attributes
static int INVALID
           
static int UNVALIDATED
           
static int VALIDATED
           
static int VALIDATING
           
protected  int validationPhase
          Flag used to check for cycles during validation
 
Constructor Summary
SchemaType()
          Default constructor.
 
Method Summary
 boolean allowsDerivation(int derivation)
          Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property
 void checkDerivation(SchemaType type, int block)
          Check that this type is validly derived from a given type
 boolean containingDeclarationIsElement()
          Determine whether the containing declaration is an element declaration or an attribute declaration
 SchemaType getBaseType()
          Returns the base type that this type inherits from.
 int getBaseTypeFingerprint()
          Get the fingerprint of the name of the base type of this type
 int getBlock()
          Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such as DERIVE_BY_LIST and DERIVE_BY_EXTENSION
 int getColumnNumber()
          Get the column number of the location where the type was defined.
 int getContainingDeclarationName()
          Get the name of the containing element or attribute declaration, if any (and if known)
 int getDerivationMethod()
          Gets the integer code of the derivation method used to derive this type from its parent.
 java.lang.String getDescription()
          Get a description of this type for use in diagnostics.
 java.lang.String getDisplayName()
          Get the display name of the type: that is, a lexical QName with an arbitrary prefix
 int getFingerprint()
          Get the fingerprint of the name of this type
 int getLineNumber()
          Get the line number of the location where the type was defined
 java.lang.String getLocalName()
          Get the local name of this type
 NamePool getNamePool()
          Get the NamePool in which the name of this type is defined
 java.lang.String getPublicId()
          Get the public ID of the location where the type was defined.
 java.lang.String getSystemId()
          Get the system ID (URI) of the schema document where the type was defined
abstract  SequenceIterator getTypedValue(NodeInfo node)
          Get the typed value of a node that is annotated with this schema type
 boolean isComplexType()
          Test whether this SchemaType is a complex type
abstract  boolean isSimpleType()
          Test whether this SchemaType is a simple type
 void setBaseType(SchemaType baseType)
          Sets the base type for this datatype.
 void setBaseTypeFingerprint(int fingerprint)
          Set the fingerprint of the name of the base type of this type.
 void setContainingDeclaration(int fingerprint, boolean isElement)
          Set the name of the containing declaration (for diagnostics)
 void setDerivationMethod(int method)
          Sets the derivation method code (without validating it)
 void setDerivationMethodName(java.lang.String method)
          Set the derivation method name.
 void setFinalProhibitions(int finalValue)
          Sets the value of the 'final' property, indicating which types of derivation are not allowed.
 void setFingerprint(int fingerprint)
          Set the fingerprint of the name of this type.
 void setLineNumber(int lineNumber)
          Set the line number at which the type is defined within a schema document
 void setLocalName(java.lang.String localName)
          Set the local name of this type
 void setLocator(javax.xml.transform.SourceLocator locator)
          Set location information for diagnostics
 void setNamePool(NamePool pool)
          Set the NamePool in which the type is defined.
 void setSystemId(java.lang.String systemId)
          Set the system identifier (URI) of the schema document in which this type is defined
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

finalProhibitions

protected int finalProhibitions
Flags used to implement the "final" and "block" attributes


DERIVE_BY_RESTRICTION

public static final int DERIVE_BY_RESTRICTION
See Also:
Constant Field Values

DERIVE_BY_EXTENSION

public static final int DERIVE_BY_EXTENSION
See Also:
Constant Field Values

DERIVE_BY_UNION

public static final int DERIVE_BY_UNION
See Also:
Constant Field Values

DERIVE_BY_LIST

public static final int DERIVE_BY_LIST
See Also:
Constant Field Values

DERIVE_BY_SUBSTITUTION

public static final int DERIVE_BY_SUBSTITUTION
See Also:
Constant Field Values

ALL_DERIVATIONS

public static final int ALL_DERIVATIONS
See Also:
Constant Field Values

validationPhase

protected int validationPhase
Flag used to check for cycles during validation


UNVALIDATED

public static final int UNVALIDATED
See Also:
Constant Field Values

VALIDATING

public static final int VALIDATING
See Also:
Constant Field Values

VALIDATED

public static final int VALIDATED
See Also:
Constant Field Values

INVALID

public static final int INVALID
See Also:
Constant Field Values
Constructor Detail

SchemaType

public SchemaType()
Default constructor. For internal use only.

Method Detail

getFingerprint

public int getFingerprint()
Get the fingerprint of the name of this type

Returns:
the fingerprint. Returns -1 for an anonymous type.

setFingerprint

public void setFingerprint(int fingerprint)
Set the fingerprint of the name of this type. For internal use only.

Parameters:
fingerprint - the fingerprint allocated in the namepool for this schema

getBaseTypeFingerprint

public int getBaseTypeFingerprint()
Get the fingerprint of the name of the base type of this type

Returns:
the fingerprint. Return -1 for an anonymous type.

setBaseTypeFingerprint

public void setBaseTypeFingerprint(int fingerprint)
Set the fingerprint of the name of the base type of this type. For internal use only.

Parameters:
fingerprint - the fingerprint allocated in the namepool

getLocalName

public java.lang.String getLocalName()
Get the local name of this type

Returns:
the local part of the name, or null if the type is anonymous

setLocalName

public void setLocalName(java.lang.String localName)
Set the local name of this type

Parameters:
localName - the local name of the type

getDisplayName

public java.lang.String getDisplayName()
Get the display name of the type: that is, a lexical QName with an arbitrary prefix

Returns:
a lexical QName identifying the type

isComplexType

public final boolean isComplexType()
Test whether this SchemaType is a complex type

Returns:
true if this SchemaType is a complex type

isSimpleType

public abstract boolean isSimpleType()
Test whether this SchemaType is a simple type

Returns:
true if this SchemaType is a simple type

getBlock

public int getBlock()
Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such as DERIVE_BY_LIST and DERIVE_BY_EXTENSION

Returns:
the value of the 'block' attribute for this type

getNamePool

public NamePool getNamePool()
Get the NamePool in which the name of this type is defined


setNamePool

public void setNamePool(NamePool pool)
Set the NamePool in which the type is defined. For internal use only.

Parameters:
pool - the NamePool containing the names in this schema

getBaseType

public SchemaType getBaseType()
Returns the base type that this type inherits from. If this type is a Simpletype that is a built in primitive type then null is returned.

Returns:
the base type.

setBaseType

public void setBaseType(SchemaType baseType)
                 throws SchemaException
Sets the base type for this datatype. For internal use only.

Parameters:
baseType - the base type which this type inherits from
SchemaException

getDerivationMethod

public int getDerivationMethod()
Gets the integer code of the derivation method used to derive this type from its parent. Returns zero for primitive types.

Returns:
a numeric code representing the derivation method, for example DERIVE_BY_RESTRICTION

allowsDerivation

public boolean allowsDerivation(int derivation)
Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property

Parameters:
derivation - the kind of derivation, for example DERIVE_BY_LIST
Returns:
true if this kind of derivation is allowed

setDerivationMethodName

public void setDerivationMethodName(java.lang.String method)
                             throws SchemaException
Set the derivation method name. For internal use only.

Parameters:
method - the derivation method, for example "restriction"
Throws:
SchemaException - for an unknown derivation method

setDerivationMethod

public void setDerivationMethod(int method)
Sets the derivation method code (without validating it)

Parameters:
method - the derivation method as an integer code, for example DERIVE_BY_UNION

setFinalProhibitions

public void setFinalProhibitions(int finalValue)
Sets the value of the 'final' property, indicating which types of derivation are not allowed. For internal use only.

Parameters:
finalValue - the value of the final property, as a bit-significant integer

checkDerivation

public void checkDerivation(SchemaType type,
                            int block)
                     throws SchemaException
Check that this type is validly derived from a given type

Parameters:
type - the type from which this type is derived
block - the derivations that are blocked by the relevant element declaration
Throws:
SchemaException - if the derivation is not allowed

getTypedValue

public abstract SequenceIterator getTypedValue(NodeInfo node)
                                        throws XPathException
Get the typed value of a node that is annotated with this schema type

Parameters:
node - the node whose typed value is required
Returns:
a SequenceIterator over the atomic values making up the typed value of the specified node. The objects returned by this iterator are of type AtomicValue
XPathException

setContainingDeclaration

public void setContainingDeclaration(int fingerprint,
                                     boolean isElement)
Set the name of the containing declaration (for diagnostics)

Parameters:
fingerprint - The fingerprint of the element or attribute declaration "owning" this anonymous type definition
isElement - True if the owning declaration is an element declaration, false if it is an attribute declaration

setLocator

public void setLocator(javax.xml.transform.SourceLocator locator)
Set location information for diagnostics

Parameters:
locator - information about the location of the type definition within a schema document

setSystemId

public void setSystemId(java.lang.String systemId)
Set the system identifier (URI) of the schema document in which this type is defined

Parameters:
systemId - the URI of the schema document

setLineNumber

public void setLineNumber(int lineNumber)
Set the line number at which the type is defined within a schema document

Parameters:
lineNumber - the line where the definition appears

getSystemId

public java.lang.String getSystemId()
Get the system ID (URI) of the schema document where the type was defined

Specified by:
getSystemId in interface javax.xml.transform.SourceLocator
Returns:
the system ID (or URI) of the containing schema document

getLineNumber

public int getLineNumber()
Get the line number of the location where the type was defined

Specified by:
getLineNumber in interface javax.xml.transform.SourceLocator
Returns:
the line number

getPublicId

public java.lang.String getPublicId()
Get the public ID of the location where the type was defined. This is always null.

Specified by:
getPublicId in interface javax.xml.transform.SourceLocator
Returns:
null

getColumnNumber

public int getColumnNumber()
Get the column number of the location where the type was defined. This is always -1, meaning unknown.

Specified by:
getColumnNumber in interface javax.xml.transform.SourceLocator
Returns:
-1

getDescription

public java.lang.String getDescription()
Get a description of this type for use in diagnostics. In the case of a named type, this is the same as the display name. In the case of a type known to be defined immediately within an element or attribute declaration, it is a phrase that identifies the containing declaration. In other cases, it is a phrase of the form "defined at line X of URI".


getContainingDeclarationName

public int getContainingDeclarationName()
Get the name of the containing element or attribute declaration, if any (and if known)

Returns:
the name of the containing declaration, as a NamePool fingerprint.

containingDeclarationIsElement

public boolean containingDeclarationIsElement()
Determine whether the containing declaration is an element declaration or an attribute declaration

Returns:
true if the containin declaration is an element declaration, false if it is an attribute