com.saxonica.schema
Class UserSimpleType

java.lang.Object
  extended bycom.saxonica.schema.SchemaStructure
      extended bycom.saxonica.schema.SchemaTypeImpl
          extended bycom.saxonica.schema.UserSimpleType
All Implemented Interfaces:
SchemaComponent, SchemaType, java.io.Serializable, SimpleType, javax.xml.transform.SourceLocator
Direct Known Subclasses:
SimpleTypeDefinition, UserAtomicType, UserListType, UserUnionType

public abstract class UserSimpleType
extends SchemaTypeImpl
implements SimpleType

This class represents a simple type, as defined in the XML Schema specification. This may be an atomic type, a list type, or a union type. In the non-schema-aware version of Saxon, the simple type will always be a built-in type. With the schema-aware product, it may also be a user-defined simple type.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.saxonica.schema.SchemaTypeImpl
finalProhibitions
 
Fields inherited from interface net.sf.saxon.type.SchemaType
DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION, DERIVE_BY_SUBSTITUTION
 
Fields inherited from interface net.sf.saxon.type.SchemaComponent
FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING
 
Constructor Summary
UserSimpleType()
           
 
Method Summary
 void analyzeContentExpression(Expression expression, int kind, StaticContext env)
          Analyze an expression to see whether the expression is capable of delivering a value of this type.
 java.lang.CharSequence applyWhitespaceNormalization(java.lang.CharSequence value)
          Apply the whitespace normalization rules for this simple type
 Value atomize(NodeInfo node)
          Get the typed value of a node that is annotated with this schema type.
 SchemaType getBuiltInBaseType()
          Returns the built-in base type this type is derived from.
 Facet getFacet(java.lang.String name)
          Returns the first facet associated with the given name, defined either on this type or on a type from which it is derived
 FacetCollection getFacetCollection()
          Get the FacetCollection for this simple type
 java.util.Iterator getFacets()
          Returns an Iterator over all the Facets (including inherited facets) for this type.
 java.util.Iterator getFacets(java.lang.String name)
          Return all the facets having the given name
 SequenceIterator getTypedValue(NodeInfo node)
          Get the typed value of a node that is annotated with this schema type
 int getWhitespaceAction(TypeHierarchy th)
          Determine the whitespace normalization required for values of this type
 boolean isAtomicType()
          Test whether this Simple Type is an atomic type
 boolean isListType()
          Returns true if this type is derived by list, or if it is derived by restriction from a list type, or if it is a union that contains a list as one of its members
 boolean isNamespaceSensitive()
          Test whether this simple type is namespace-sensitive, that is, whether it is derived from xs:QName or xs:NOTATION
 boolean isSimpleType()
          Returns true if this SchemaType is a SimpleType
 void isTypeDerivationOK(SchemaType type, int block)
          Check that this type is validly derived from a given type
static java.lang.String isTypeDerivationOK(SimpleType d, SchemaType b, int derivation)
          Check whether type derivation is allowed.
 boolean isUnionType()
          Return true if this type is a union type (that is, if its variety is union)
 void setFacetCollection(FacetCollection facets)
          Set the FacetCollection for this simple type.
 boolean validate(PreparedSchema schema)
          Checks the validity of this SimpleType definition.
 
Methods inherited from class com.saxonica.schema.SchemaTypeImpl
allowsDerivation, containingDeclarationIsElement, getBaseType, getBaseTypeFingerprint, getBaseTypeReference, getBlock, getContainingDeclarationName, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getLocalName, getNameCode, getNamePool, isComplexType, isSameType, setBaseTypeReference, setContainingDeclaration, setDerivationMethod, setDerivationMethodName, setFinalProhibitions, setLocalName, setNameCode, setNamePool
 
Methods inherited from class com.saxonica.schema.SchemaStructure
getColumnNumber, getFixupStatus, getLineNumber, getPublicId, getSchema, getSystemId, getValidationStatus, lookForCycles, setFixupStatus, setLineNumber, setLocator, setSchema, setSystemId, setValidationStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.type.SimpleType
getCommonAtomicType, getTypedValue, validateContent
 
Methods inherited from interface net.sf.saxon.type.SchemaType
allowsDerivation, getBaseType, getBlock, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getNameCode, isComplexType, isSameType
 
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getValidationStatus
 

Constructor Detail

UserSimpleType

public UserSimpleType()
Method Detail

isSimpleType

public final boolean isSimpleType()
Returns true if this SchemaType is a SimpleType

Specified by:
isSimpleType in interface SchemaType
Returns:
true (always)

isAtomicType

public boolean isAtomicType()
Test whether this Simple Type is an atomic type

Specified by:
isAtomicType in interface SimpleType
Returns:
false - actually, we don't yet know the answer.

isListType

public boolean isListType()
Returns true if this type is derived by list, or if it is derived by restriction from a list type, or if it is a union that contains a list as one of its members

Specified by:
isListType in interface SimpleType
Returns:
true if this is a list type

isUnionType

public boolean isUnionType()
Return true if this type is a union type (that is, if its variety is union)

Specified by:
isUnionType in interface SimpleType
Returns:
true for a union type

setFacetCollection

public void setFacetCollection(FacetCollection facets)
Set the FacetCollection for this simple type. For internal use only.

Parameters:
facets - the collection of facets for this type.

getFacetCollection

public FacetCollection getFacetCollection()
Get the FacetCollection for this simple type

Returns:
a FacetCollection containing all the facets locally declared on this simple type (and providing access to the inherited facets also)

getFacet

public Facet getFacet(java.lang.String name)
               throws ValidationException
Returns the first facet associated with the given name, defined either on this type or on a type from which it is derived

Returns:
the first facet associated with the given name
Throws:
ValidationException

getFacets

public java.util.Iterator getFacets(java.lang.String name)
                             throws ValidationException
Return all the facets having the given name

Returns:
an iterator over all the facets with the given name, including those defined on a type from which this is derived by restriction or by union
Throws:
ValidationException

getFacets

public java.util.Iterator getFacets()
                             throws ValidationException
Returns an Iterator over all the Facets (including inherited facets) for this type.

Returns:
an Iterator over all the Facets for this type.
Throws:
ValidationException

getWhitespaceAction

public int getWhitespaceAction(TypeHierarchy th)
Determine the whitespace normalization required for values of this type

Specified by:
getWhitespaceAction in interface SimpleType
Parameters:
th -
Returns:
one of PRESERVE, REPLACE, COLLAPSE
Throws:
java.lang.IllegalStateException - if the simple type is not fully validated and the whitespace facet is not yet known.

applyWhitespaceNormalization

public java.lang.CharSequence applyWhitespaceNormalization(java.lang.CharSequence value)
                                                    throws ValidationException
Apply the whitespace normalization rules for this simple type

Parameters:
value - the string before whitespace normalization
Returns:
the string after whitespace normalization
Throws:
ValidationException

getBuiltInBaseType

public SchemaType getBuiltInBaseType()
                              throws ValidationException
Returns the built-in base type this type is derived from.

Specified by:
getBuiltInBaseType in interface SimpleType
Returns:
the first built-in type found when searching up the type hierarchy
Throws:
ValidationException

isNamespaceSensitive

public boolean isNamespaceSensitive()
Test whether this simple type is namespace-sensitive, that is, whether it is derived from xs:QName or xs:NOTATION

Specified by:
isNamespaceSensitive in interface SimpleType
Returns:
true if this type is derived from xs:QName or xs:NOTATION

isTypeDerivationOK

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

Specified by:
isTypeDerivationOK in interface SchemaType
Overrides:
isTypeDerivationOK in class SchemaTypeImpl
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
ValidationException

isTypeDerivationOK

public static java.lang.String isTypeDerivationOK(SimpleType d,
                                                  SchemaType b,
                                                  int derivation)
                                           throws ValidationException
Check whether type derivation is allowed. This implements the Schema Component Constraint: Type Derivation OK (Simple). This type is D (the derived type); the type supplied as an argument is B (the base type), and the argument (a subset (extension, restriction, list, union)) is provided in the second argument. If type derivation is allowed, the method return null; otherwise it returns a string that can be used as an error message

Parameters:
b - the base type
derivation - the disallowed derivations, as a bit-significant integer
Returns:
null if type derivation is OK; otherwise a string that can be used as an error message
Throws:
ValidationException

validate

public boolean validate(PreparedSchema schema)
                 throws SchemaException,
                        UnresolvedReferenceException,
                        ValidationException
Checks the validity of this SimpleType definition.

Parameters:
schema - a Schema used for error reporting
Throws:
SchemaException - if this SimpleType definition is invalid.
UnresolvedReferenceException
ValidationException

analyzeContentExpression

public void analyzeContentExpression(Expression expression,
                                     int kind,
                                     StaticContext env)
                              throws XPathException
Analyze an expression to see whether the expression is capable of delivering a value of this type.

Specified by:
analyzeContentExpression in interface SchemaType
Parameters:
expression - the expression that delivers the content
kind - the node kind whose content is being delivered: Type.ELEMENT, Type.ATTRIBUTE, or Type.DOCUMENT
env -
Throws:
XPathException - if the expression will never deliver a value of the correct type

getTypedValue

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

Specified by:
getTypedValue in interface SchemaType
Parameters:
node - the node whose typed value is required
Returns:
an iterator over the items making up the typed value of this node. The objects returned by this SequenceIterator will all be of type AtomicValue
Throws:
XPathException

atomize

public Value atomize(NodeInfo node)
              throws XPathException
Get the typed value of a node that is annotated with this schema type. The result of this method will always be consistent with the method getTypedValue(net.sf.saxon.om.NodeInfo). However, this method is often more convenient and may be more efficient, especially in the common case where the value is expected to be a singleton.

Specified by:
atomize in interface SchemaType
Parameters:
node - the node whose typed value is required
Returns:
the typed value.
Throws:
XPathException
Since:
8.5