Package com.saxonica.ee.schema
Class UserUnionType
- java.lang.Object
-
- com.saxonica.ee.schema.SchemaStructure
-
- com.saxonica.ee.schema.UserDefinedType
-
- com.saxonica.ee.schema.UserSimpleType
-
- com.saxonica.ee.schema.UserUnionType
-
- All Implemented Interfaces:
SerializableSchemaComponent,UserSchemaComponent,javax.xml.transform.SourceLocator,Location,CastingTarget,ItemType,PlainType,SchemaComponent,SchemaType,SimpleType,UnionType,org.xml.sax.Locator
public class UserUnionType extends UserSimpleType implements PlainType, UnionType
A class that represents the XML Schema simple-type with variety union.A "plain" union is a union that is not derived by restriction and whose member types are all either atomic types or plain union types. Only plain union types can be named in the XPath SequenceType production. (All union types, however, can act as the target of a cast expression). This class implements the interface
PlainTypedespite the fact that not all its instances represent plain unions; to test whether a union is a plain union, use theisPlainType()method.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sf.saxon.type.ItemType
ItemType.WithSequenceTypeCache
-
Nested classes/interfaces inherited from interface net.sf.saxon.type.SchemaComponent
SchemaComponent.ValidationStatus
-
-
Field Summary
-
Fields inherited from class com.saxonica.ee.schema.UserDefinedType
extendedTypes, finalProhibitions
-
Fields inherited from interface net.sf.saxon.type.SchemaComponent
COMPONENT_FUNCTION_TYPE
-
Fields inherited from interface net.sf.saxon.type.SchemaType
DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION, DERIVE_BY_SUBSTITUTION
-
-
Constructor Summary
Constructors Constructor Description UserUnionType(EnterpriseConfiguration config)Creates a new Union type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMemberTypeReference(TypeReference member)Add a member type to the list of member typesValidationFailurecheckAgainstFacets(AtomicValue value, ConversionRules rules)Validate an atomic value, which is known to be an instance of one of the member types of the union, against any facets (pattern facets or enumeration facets) defined at the level of the union itself.booleancontainsListType()Ask whether this union type includes any list types among its membersvoidelaborate(SchemaCompiler compiler)Elaborate the schema component: after reloading a serialized schema component model, this expands the component with derived information needed during validation episodes.PlainTypegetAtomizedItemType()Get the item type of the atomic values that will be produced when an item of this type is atomizedjava.lang.StringgetBasicAlphaCode()Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived.doublegetDefaultPriority()Get the default priority when this ItemType is used as an XSLT patternjava.lang.StringgetDescription()Get a description of this type for use in diagnostics.GenregetGenre()Get the genre of this itemjava.util.List<TypeReference>getMemberTypeReferences()Get the list of member typesjava.lang.Iterable<PlainType>getPlainMemberTypes()Get the list of plain types that are subsumed by this typeAtomicTypegetPrimitiveItemType()Method defined in ItemType: get a primitive supertype in the ItemType type hierarchyintgetPrimitiveType()Method defined in ItemType: get a primitive supertype in the ItemType type hierarchySequenceTypegetResultTypeOfCast()Get the SequenceType that most accurately describes the result of casting a value to this union typeStructuredQNamegetStructuredQName()Get the name of the type as a StructuredQNameAtomicSequencegetTypedValue(java.lang.CharSequence value, NamespaceResolver resolver, ConversionRules rules)Get the typed value corresponding to a given string value, assuming it is valid against this typeUTypegetUType()Get the correspondingUType.booleanisAtomicType()Ask whether this Simple Type is an atomic typebooleanisAtomizable(TypeHierarchy th)Ask whether values of this type are atomizablebooleanisBuiltInType()Determine whether this is a built-in type or a user-defined typebooleanisIdRefType()Ask whether this type is an IDREF or IDREFS type.booleanisIdType()Ask whether this type is an ID type.booleanisListType()Determine whether this is a list typebooleanisNamespaceSensitive()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.booleanisPlainType()Ask whether this Union type is a "plain type", defined as a union type whose member types are all atomic types or plain unions.booleanisTrueItemType()Ask whether thisItemTypeactually represents an item type in the XDM sense of the term.booleanisUnionType()Return true if this type is a union type (that is, if its variety is union)voidlookForCycles(java.util.Stack references, SchemaCompiler compiler)This method is called to look for cycles.booleanmatches(Item item, TypeHierarchy th)Test whether a given item conforms to this typevoidserializeVariety(SchemaModelSerializer serializer)Serialize the schema componentvoidsetMemberTypeReferences(java.util.List<TypeReference> members)Set the member types of this union type.java.lang.StringtoExportString()Return a string representation of this ItemType suitable for use in stylesheet export files.java.lang.StringtoString()Produce a string representation of the type name.booleanvalidate(SchemaCompiler compiler)Validate this Union, replacing all unresolved forwards references at the same timeValidationFailurevalidateContent(java.lang.CharSequence value, NamespaceResolver nsResolver, ConversionRules rules)Check whether a given input string is valid according to this SimpleType-
Methods inherited from class com.saxonica.ee.schema.UserSimpleType
addFacet, addInheritedFacets, analyzeContentExpression, applyWhitespaceNormalization, atomize, checkAgainstFacets, checkTypeDerivationIsOK, convertFacetValues, getBuiltInBaseType, getComponentAsFunction, getComponentAsFunction, getContextComponent, getEQName, getExtendedFacetList, getFacet, getLocalFacetList, getWhitespaceAction, isSimpleType, isTypeDerivationOK, makeValidationFailure, mergeEnumerationFacets, postprocess, preprocess, serialize, setContextComponent, setFacetList
-
Methods inherited from class com.saxonica.ee.schema.UserDefinedType
allowsDerivation, containingDeclarationIsElement, getBaseType, getBaseTypeFingerprint, getBaseTypeReference, getBlock, getContainingDeclarationName, getDerivationMethod, getDisplayName, getExtensionTypes, getFinalProhibitions, getFingerprint, getName, getNamePool, getTargetNamespace, getTypeName, isAnonymousType, isComplexType, isSameType, isSameURI, registerExtensionType, setBaseTypeReference, setContainingDeclaration, setDerivationMethod, setDerivationMethodName, setExtendedTypes, setFinalProhibitions, setTypeName
-
Methods inherited from class com.saxonica.ee.schema.SchemaStructure
fixup, getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.type.ItemType
getFullAlphaCode, getNormalizedDefaultPriority
-
Methods inherited from interface net.sf.saxon.type.PlainType
getTypeName
-
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatus
-
Methods inherited from interface net.sf.saxon.type.SchemaType
allowsDerivation, getBaseType, getBlock, getDerivationMethod, getDisplayName, getFinalProhibitions, getFingerprint, getName, getNearestNamedType, getSystemId, getTargetNamespace, isAnonymousType, isComplexType, isSameType
-
Methods inherited from interface net.sf.saxon.type.UnionType
explainMismatch, getTypeName
-
Methods inherited from interface com.saxonica.ee.schema.UserSchemaComponent
fixup
-
-
-
-
Constructor Detail
-
UserUnionType
public UserUnionType(EnterpriseConfiguration config)
Creates a new Union type.- Parameters:
config- the Configuration for this Union (Cannot be null)
-
-
Method Detail
-
getGenre
public Genre getGenre()
Get the genre of this item
-
getStructuredQName
public StructuredQName getStructuredQName()
Get the name of the type as a StructuredQName- Specified by:
getStructuredQNamein interfaceSchemaType- Specified by:
getStructuredQNamein interfaceUnionType- Overrides:
getStructuredQNamein classUserDefinedType- Returns:
- a StructuredQName identifying the type. In the case of an anonymous type, an internally-generated name is returned
-
setMemberTypeReferences
public void setMemberTypeReferences(java.util.List<TypeReference> members)
Set the member types of this union type.- Parameters:
members- a list ofTypeReferenceobjects
-
addMemberTypeReference
public void addMemberTypeReference(TypeReference member)
Add a member type to the list of member types- Parameters:
member- a reference to a new member type
-
getMemberTypeReferences
public java.util.List<TypeReference> getMemberTypeReferences()
Get the list of member types- Returns:
- a List containing
TypeReferenceobjects
-
isAtomicType
public boolean isAtomicType()
Ask whether this Simple Type is an atomic type- Specified by:
isAtomicTypein interfaceItemType- Specified by:
isAtomicTypein interfaceSchemaType- Specified by:
isAtomicTypein interfaceSimpleType- Overrides:
isAtomicTypein classUserSimpleType- Returns:
- false, this is not an atomic type
-
containsListType
public boolean containsListType() throws MissingComponentExceptionAsk whether this union type includes any list types among its members- Specified by:
containsListTypein interfaceUnionType- Returns:
- true of one of the member types is a list type
- Throws:
MissingComponentException
-
isPlainType
public boolean isPlainType()
Ask whether this Union type is a "plain type", defined as a union type whose member types are all atomic types or plain unions. That is, it disallows unions that are derived by restriction from another union. The significance of this is that an atomic value will never match a non-plain union type- Specified by:
isPlainTypein interfaceItemType- Returns:
- true if this is ANY_ATOMIC_TYPE or a subtype thereof, or a "plain" union type (that is, unions of atomic types that impose no further restrictions). Return false if this is a union type whose member types are not all known.
-
isTrueItemType
public boolean isTrueItemType()
Description copied from interface:ItemTypeAsk whether thisItemTypeactually represents an item type in the XDM sense of the term. The only instances that aren't true item types are user-defined union types derived by restriction from other union types or containing list types in their transitive membership ("impure union types")- Specified by:
isTrueItemTypein interfaceItemType- Returns:
- true if this is a true item type in the XDM sense
-
getResultTypeOfCast
public SequenceType getResultTypeOfCast()
Get the SequenceType that most accurately describes the result of casting a value to this union type- Specified by:
getResultTypeOfCastin interfaceUnionType- Returns:
- the most precise SequenceType for the result of casting
-
isIdType
public boolean isIdType() throws MissingComponentExceptionAsk whether this type is an ID type. This is defined to be any simple type who typed value may contain atomic values of type xs:ID: that is, it includes types derived from ID by restriction, list, or union. Note that for a node to be treated as an ID in XSD 1.0, its typed value must be a *single* atomic value of type ID; the type of the node, however, can still allow a list or union. This changes in XSD 1.1, where a list of IDs is allowed.- Specified by:
isIdTypein interfaceSchemaType- Overrides:
isIdTypein classUserSimpleType- Returns:
- true if this type is an ID type
- Throws:
MissingComponentException
-
isIdRefType
public boolean isIdRefType() throws MissingComponentExceptionAsk whether this type is an IDREF or IDREFS type. This is defined to be any simple type who typed value may contain atomic values of type xs:IDREF: that is, it includes types derived from IDREF or IDREFS by restriction, list, or union- Specified by:
isIdRefTypein interfaceSchemaType- Overrides:
isIdRefTypein classUserSimpleType- Returns:
- true if this type is an IDREF type
- Throws:
MissingComponentException
-
isBuiltInType
public boolean isBuiltInType()
Determine whether this is a built-in type or a user-defined type- Specified by:
isBuiltInTypein interfaceSimpleType- Returns:
- true if this is a built-in type
-
isListType
public boolean isListType()
Determine whether this is a list type- Specified by:
isListTypein interfaceSimpleType- Overrides:
isListTypein classUserSimpleType- 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:
isUnionTypein interfaceSimpleType- Overrides:
isUnionTypein classUserSimpleType- Returns:
- true for a union type
-
getUType
public UType getUType()
Get the correspondingUType. A UType is a union of primitive item types.
-
getBasicAlphaCode
public java.lang.String getBasicAlphaCode()
Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived. The codes are designed so that for any two built-in types A and B, alphaCode(A) is a prefix of alphaCode(B) if and only if A is a supertype of B.- Specified by:
getBasicAlphaCodein interfaceItemType- Returns:
- the alphacode for the nearest containing 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:
isNamespaceSensitivein interfacePlainType- Specified by:
isNamespaceSensitivein interfaceSimpleType- Returns:
- true if any of the member types is namespace-sensitive, or if namespace sensitivity cannot be determined because there are components missing from the schema.
-
validate
public boolean validate(SchemaCompiler compiler) throws SchemaException
Validate this Union, replacing all unresolved forwards references at the same time- Specified by:
validatein interfaceUserSchemaComponent- Overrides:
validatein classUserSimpleType- Parameters:
compiler- used for error reporting- Returns:
- true when this Schema definition is valid, otherwise false.
- Throws:
SchemaException- if the definition is invalid
-
elaborate
public void elaborate(SchemaCompiler compiler) throws SchemaException
Description copied from class:UserSimpleTypeElaborate the schema component: after reloading a serialized schema component model, this expands the component with derived information needed during validation episodes. The model is assumed to be valid.- Specified by:
elaboratein interfaceUserSchemaComponent- Overrides:
elaboratein classUserSimpleType- Parameters:
compiler- the schema compiler- Throws:
SchemaException- if a fatal error occurs
-
lookForCycles
public void lookForCycles(java.util.Stack references, SchemaCompiler compiler) throws SchemaExceptionThis method is called to look for cycles. The object implementing this method is required (a) to raise an exception if the object itself appears in the list of references, (b) to add itself to the list of references, and (c) to call the lookForCycles method on all the objects that it references.- Specified by:
lookForCyclesin interfaceUserSchemaComponent- Overrides:
lookForCyclesin classSchemaStructure- Parameters:
references- A list of objects that contain direct or indirect references to this object, and that must therefore not be referred to from this object.compiler- used for error reporting- Throws:
SchemaException- if cycles are found
-
validateContent
public ValidationFailure validateContent(java.lang.CharSequence value, NamespaceResolver nsResolver, ConversionRules rules)
Check whether a given input string is valid according to this SimpleType- Specified by:
validateContentin interfaceSimpleType- Parameters:
value- the input string to be checkednsResolver- 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.rules- the configuration-wide conversion rules- Returns:
- null if validation succeeds; return a ValidationFailure describing the validation failure if validation fails
- Throws:
java.lang.UnsupportedOperationException- if the type is namespace-sensitive and no namespace resolver is supplied
-
checkAgainstFacets
public ValidationFailure checkAgainstFacets(AtomicValue value, ConversionRules rules)
Validate an atomic value, which is known to be an instance of one of the member types of the union, against any facets (pattern facets or enumeration facets) defined at the level of the union itself.- Specified by:
checkAgainstFacetsin interfaceUnionType- Parameters:
value- the Atomic Value to be checked. This must be an instance of a member type of the unionrules- the ConversionRules for the Configuration- Returns:
- a ValidationFailure if the value is not valid; null if it is valid.
-
getTypedValue
public AtomicSequence getTypedValue(java.lang.CharSequence value, NamespaceResolver resolver, ConversionRules rules) throws ValidationException
Description copied from interface:UnionTypeGet the typed value corresponding to a given string value, assuming it is valid against this type- Specified by:
getTypedValuein interfaceSimpleType- Specified by:
getTypedValuein interfaceUnionType- Parameters:
value- the string valueresolver- a namespace resolver used to resolve any namespace prefixes appearing in the content of values. Can supply null, in which case any namespace-sensitive content will be rejected.rules- the conversion rules from the configuration- Returns:
- the atomic sequence comprising the typed value. The objects
returned by this SequenceIterator will all be of type
AtomicValue, - Throws:
ValidationException- if the supplied value is not in the lexical space of the data type
-
serializeVariety
public void serializeVariety(SchemaModelSerializer serializer) throws XPathException
Serialize the schema component- Specified by:
serializeVarietyin classUserSimpleType- Throws:
XPathException
-
matches
public boolean matches(Item item, TypeHierarchy th)
Test whether a given item conforms to this type
-
getPrimitiveItemType
public AtomicType getPrimitiveItemType()
Method defined in ItemType: get a primitive supertype in the ItemType type hierarchy- Specified by:
getPrimitiveItemTypein interfaceItemType- Specified by:
getPrimitiveItemTypein interfacePlainType- Returns:
- BuiltInAtomicType.ANY_ATOMIC
-
getPrimitiveType
public int getPrimitiveType()
Method defined in ItemType: get a primitive supertype in the ItemType type hierarchy- Specified by:
getPrimitiveTypein interfaceItemType- Returns:
- StandardNames.XS_ANY_ATOMIC_TYPE
-
getAtomizedItemType
public PlainType getAtomizedItemType()
Description copied from interface:ItemTypeGet the item type of the atomic values that will be produced when an item of this type is atomized- Specified by:
getAtomizedItemTypein interfaceItemType- Returns:
- the best available item type of the atomic values that will be produced when an item of this type is atomized, or null if it is known that atomization will throw an error.
-
isAtomizable
public boolean isAtomizable(TypeHierarchy th)
Description copied from interface:ItemTypeAsk whether values of this type are atomizable- Specified by:
isAtomizablein interfaceItemType- Parameters:
th- the type hierarchy cache- Returns:
- true if some or all instances of this type can be successfully atomized; false if no instances of this type can be atomized
-
getPlainMemberTypes
public java.lang.Iterable<PlainType> getPlainMemberTypes() throws MissingComponentException
Get the list of plain types that are subsumed by this type- Specified by:
getPlainMemberTypesin interfacePlainType- Specified by:
getPlainMemberTypesin interfaceUnionType- Returns:
- for an atomic type, the type itself; for a plain union type, the list of plain types in its transitive membership, in declaration order
- Throws:
MissingComponentException
-
getDefaultPriority
public double getDefaultPriority()
Get the default priority when this ItemType is used as an XSLT pattern- Specified by:
getDefaultPriorityin interfaceItemType- Returns:
- the default priority. For a union type this is defined as the product of the default priorities of the member types. Because the priorities of member types are in the range 0 to 1, their product is also in the range 0 to 1.
-
toString
public java.lang.String toString()
Produce a string representation of the type name. If the type is anonymous, an internally-allocated type name will be returned.- Specified by:
toStringin interfaceItemType- Overrides:
toStringin classUserDefinedType- Returns:
- the name of the atomic type in the form Q{uri}local
-
toExportString
public java.lang.String toExportString()
Description copied from interface:ItemTypeReturn a string representation of this ItemType suitable for use in stylesheet export files. This differs from the result of toString() in that it will not contain any references to anonymous types. Note that it may also use the Saxon extended syntax for union types and tuple types. The default implementation returns the result of callingtoString().- Specified by:
toExportStringin interfaceItemType- Returns:
- the string representation as an instance of the XPath SequenceType construct
-
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 L of URI". The description is designed to be inserted in a context such as "the type X is ..."- Specified by:
getDescriptionin interfaceSchemaType- Specified by:
getDescriptionin interfaceUnionType- Overrides:
getDescriptionin classUserDefinedType- Returns:
- text identifing the type, for use in a phrase such as "the type XXXX".
-
-