com.saxonica.sdoc
Class SimpleTypeDefinition

java.lang.Object
  extended by com.saxonica.schema.SchemaStructure
      extended by com.saxonica.schema.UserDefinedType
          extended by com.saxonica.schema.UserSimpleType
              extended by com.saxonica.sdoc.SimpleTypeDefinition
All Implemented Interfaces:
SerializableSchemaComponent, UserSchemaComponent, Serializable, SourceLocator, SchemaComponent, SchemaType, SimpleType

public class SimpleTypeDefinition
extends UserSimpleType
implements UserSchemaComponent

A simple type definition holds all the information about a simpleType during the course of schema processing. On completion of schema processing, more specific objects are created, for example ListType, AtomicType, or UnionType, and the SimpleTypeDefinition is then discarded.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.saxonica.schema.UserDefinedType
extendedTypes, finalProhibitions
 
Fields inherited from interface net.sf.saxon.type.SchemaComponent
FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING
 
Fields inherited from interface net.sf.saxon.type.SimpleType
VARIETY_ATOMIC, VARIETY_LIST, VARIETY_UNION, VARIETY_UNSPECIFIED_SIMPLE
 
Fields inherited from interface net.sf.saxon.type.SchemaType
DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION, DERIVE_BY_SUBSTITUTION
 
Constructor Summary
SimpleTypeDefinition(EnterpriseConfiguration config)
          Create a SimpleTypeDefinition
 
Method Summary
 void addMemberType(TypeReference memberType)
          Add a member type to this union type
 boolean fixup(SchemaCompiler compiler)
          Check references from this component to other components
 AtomicType getCommonAtomicType()
          Get the most specific possible atomic type that all items in this SimpleType belong to
 UserSimpleType getSimpleType()
          Get the simple type created for this definition
 SequenceIterator getTypedValue(CharSequence value, NamespaceResolver resolver, NameChecker nameChecker)
          Get the typed value corresponding to a given string value, assuming it is valid against this type
 boolean isBuiltInType()
          Determine whether this is a built-in type or a user-defined 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 type is namespace sensitive, that is, if a namespace context is needed to translate between the lexical space and the value space.
 boolean isUnionType()
          Return true if this type is a union type (that is, if its variety is union), which will be true if is derived by union, or if it is derived by restriction from a type whose variety is union.
 void serialize(SchemaModelSerializer serializer)
          Serialize the schema component
protected  void serializeVariety(SchemaModelSerializer serializer)
           
 void setIsSimpleContent(boolean b)
          Indicate that this simple type represents the content type of a complex type with simple content
 void setItemTypeReference(TypeReference itemType)
          Set the reference to an item type of this list type
 boolean validate(SchemaCompiler compiler)
          Checks the validity of this SimpleType definition.
 ValidationFailure validateContent(CharSequence value, NamespaceResolver nsResolver, NameChecker nameChecker)
          Check whether a given input string is valid according to this SimpleType
 
Methods inherited from class com.saxonica.schema.UserSimpleType
addFacet, addInheritedFacets, analyzeContentExpression, applyWhitespaceNormalization, atomize, checkAgainstFacets, checkTypeDerivationIsOK, convertFacetValues, elaborate, getBuiltInBaseType, getExtendedFacetList, getFacet, getFacets, getLocalFacetList, getTypedValue, getWhitespaceAction, isAtomicType, isIdRefType, isIdType, isSimpleType, isTypeDerivationOK, mergeEnumerationFacets, postprocess, preprocess, setFacetList
 
Methods inherited from class com.saxonica.schema.UserDefinedType
allowsDerivation, containingDeclarationIsElement, getBaseType, getBaseTypeFingerprint, getBaseTypeReference, getBlock, getContainingDeclarationName, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getLocalName, getName, getNameCode, getNamePool, getTargetNamespace, hasRegisteredExtension, isAnonymousType, isComplexType, isExternalType, isSameType, iterateExtensionTypes, registerExtensionType, setBaseTypeReference, setContainingDeclaration, setDerivationMethod, setDerivationMethodName, setExtendedTypes, setFinalProhibitions, setNameCode
 
Methods inherited from class com.saxonica.schema.SchemaStructure
getColumnNumber, getConfiguration, getFixupStatus, getLineNumber, getPublicId, getRedefinitionLevel, getSystemId, getValidationStatus, lookForCycles, setConfiguration, setFixupStatus, setLineNumber, setLocator, setRedefinitionLevel, setSystemId, setValidationStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.saxonica.schema.UserSchemaComponent
elaborate, lookForCycles
 
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatus
 
Methods inherited from interface net.sf.saxon.type.SimpleType
isExternalType
 
Methods inherited from interface net.sf.saxon.type.SchemaType
allowsDerivation, getBaseType, getBlock, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getName, getNameCode, getSystemId, getTargetNamespace, isAnonymousType, isComplexType, isSameType
 

Constructor Detail

SimpleTypeDefinition

public SimpleTypeDefinition(EnterpriseConfiguration config)
Create a SimpleTypeDefinition

Parameters:
config - the Saxon configuration
Method Detail

setItemTypeReference

public void setItemTypeReference(TypeReference itemType)
Set the reference to an item type of this list type

Parameters:
itemType - reference to a type forming the item type of this list type

isListType

public boolean isListType()
Description copied from class: UserSimpleType
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
Overrides:
isListType in class UserSimpleType
Returns:
true if this is a list type

isUnionType

public boolean isUnionType()
Description copied from class: UserSimpleType
Return true if this type is a union type (that is, if its variety is union), which will be true if is derived by union, or if it is derived by restriction from a type whose variety is union.

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

setIsSimpleContent

public void setIsSimpleContent(boolean b)
Indicate that this simple type represents the content type of a complex type with simple content

Parameters:
b - true if this is the content type of a complex type with simple content

addMemberType

public void addMemberType(TypeReference memberType)
Add a member type to this union type

Parameters:
memberType - the member type to be added

getSimpleType

public UserSimpleType getSimpleType()
Get the simple type created for this definition

Returns:
the UserSimpleType object if it has been created, otherwise null

getCommonAtomicType

public AtomicType getCommonAtomicType()
Get the most specific possible atomic type that all items in this SimpleType belong to

Specified by:
getCommonAtomicType in interface SimpleType
Returns:
the lowest common supertype of all member types

fixup

public boolean fixup(SchemaCompiler compiler)
              throws SchemaException
Check references from this component to other components

Specified by:
fixup in interface UserSchemaComponent
Overrides:
fixup in class SchemaStructure
Parameters:
compiler - used for error reporting
Returns:
true if all is well, false if errors found
Throws:
SchemaException

validate

public boolean validate(SchemaCompiler compiler)
                 throws SchemaException
Checks the validity of this SimpleType definition.

Specified by:
validate in interface UserSchemaComponent
Overrides:
validate in class UserSimpleType
Parameters:
compiler - used for error reporting
Returns:
true when this Schema definition is valid, otherwise false.
Throws:
SchemaException - when this SimpleType definition is invalid.

getTypedValue

public SequenceIterator getTypedValue(CharSequence value,
                                      NamespaceResolver resolver,
                                      NameChecker nameChecker)
                               throws ValidationException
Get the typed value corresponding to a given string value, assuming it is valid against this type

Specified by:
getTypedValue in interface SimpleType
Parameters:
value - the string value
resolver - a namespace resolver used to resolve prefixes in QNames and notations
nameChecker - used to check names against XML 1.0 or XML 1.1 rules
Returns:
an iterator over the atomic sequence comprising the typed value
Throws:
ValidationException - if the supplied value is not in the lexical space of the data type

isBuiltInType

public boolean isBuiltInType()
Determine whether this is a built-in type or a user-defined type

Specified by:
isBuiltInType in interface SimpleType
Returns:
true if this is a built-in type

isNamespaceSensitive

public boolean isNamespaceSensitive()
Test whether this type is namespace sensitive, that is, if a namespace context is needed to translate between the lexical space and the value space. This is true for types derived from, or containing, QNames and NOTATIONs

Specified by:
isNamespaceSensitive in interface SimpleType
Returns:
true if the type is namespace-sensitive

validateContent

public ValidationFailure validateContent(CharSequence value,
                                         NamespaceResolver nsResolver,
                                         NameChecker nameChecker)
Check whether a given input string is valid according to this SimpleType

Specified by:
validateContent in interface SimpleType
Parameters:
value - the input string to be checked
nsResolver - a namespace resolver used to resolve namespace prefixes if the type is namespace sensitive. The value supplied may be null; in this case any namespace-sensitive content will throw an UnsupportedOperationException.
nameChecker - Used to check the syntax of names against the XML 1.0 or XML 1.1 rules
Returns:
null if validation succeeds; return a ValidationFailure describing the validation failure if validation fails. Note that the exception is returned rather than being thrown.
Throws:
UnsupportedOperationException - if the type is namespace-sensitive and no namespace resolver is supplied

serialize

public void serialize(SchemaModelSerializer serializer)
Serialize the schema component

Specified by:
serialize in interface SerializableSchemaComponent
Overrides:
serialize in class UserSimpleType

serializeVariety

protected void serializeVariety(SchemaModelSerializer serializer)
                         throws XPathException
Specified by:
serializeVariety in class UserSimpleType
Throws:
XPathException


Copyright (c) Saxonica Limited. All rights reserved.