Package net.sf.saxon.type
Class AnyType
- java.lang.Object
-
- net.sf.saxon.type.AnyType
-
- All Implemented Interfaces:
java.io.Serializable,ComplexType,SchemaComponent,SchemaType
public final class AnyType extends java.lang.Object implements ComplexType, java.io.Serializable
This class has a singleton instance which represents the XML Schema built-in type xs:anyType, also known as the urtype.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface net.sf.saxon.type.SchemaComponent
FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING
-
Fields inherited from interface net.sf.saxon.type.SchemaType
DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION, DERIVE_BY_SUBSTITUTION
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowsDerivation(int derivation)Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" propertyvoidanalyzeContentExpression(Expression expression, int kind, StaticContext env)Analyze an expression to see whether the expression is capable of delivering a value of this type.Valueatomize(NodeInfo node)Get the typed value of a node that is annotated with this schema type.voidcheckTypeDerivationIsOK(SchemaType type, int block)Check that this type is validly derived from a given typeSchemaTypegetAttributeUseType(int fingerprint)Find an attribute use within this complex type definition having a given attribute name (identified by fingerprint), and return the schema type associated with that attribute.SchemaTypegetBaseType()Get the base typeintgetBlock()Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such asSchemaType.DERIVATION_LISTandSchemaType.DERIVATION_EXTENSIONintgetDerivationMethod()Gets the integer code of the derivation method used to derive this type from its parent.java.lang.StringgetDescription()Get a description of this type for use in diagnosticsjava.lang.StringgetDisplayName()Get the display name of the type: that is, a lexical QName with an arbitrary prefixintgetElementParticleCardinality(int fingerprint)Find an element particle within this complex type definition having a given element name (identified by fingerprint), and return the cardinality associated with that element particle, that is, the number of times the element can occur within this complex type.SchemaTypegetElementParticleType(int fingerprint)Find an element particle within this complex type definition having a given element name (identified by fingerprint), and return the schema type associated with that element particle.intgetFingerprint()Get the fingerprint of the name of this typestatic AnyTypegetInstance()Get the singular instance of this classSchemaTypegetKnownBaseType()Returns the base type that this type inherits from.intgetNameCode()Get the namecode of the name of this type.SimpleTypegetSimpleContentType()For a complex type with simple content, return the simple type of the content.SequenceIteratorgetTypedValue(NodeInfo node)Get the typed value of a node that is annotated with this schema typeintgetValidationStatus()Get the validation status - always validbooleanisAbstract()Test whether this ComplexType has been marked as abstract.booleanisAllContent()Test whether this complex type has "all" content, that is, a content model using an xs:all compositorbooleanisAnonymousType()Test whether this is an anonymous typebooleanisAtomicType()Test whether this SchemaType is an atomic typebooleanisComplexContent()Test whether this complex type has complex contentbooleanisComplexType()Test whether this SchemaType is a complex typebooleanisEmptiable()Test whether the content model of this complexType allows empty contentbooleanisEmptyContent()Test whether the content type of this complex type is emptybooleanisMixedContent()Test whether this complex type allows mixed contentbooleanisRestricted()Test whether this complex type is derived by restrictionbooleanisSameType(SchemaType other)Test whether this is the same type as another type.booleanisSimpleContent()Test whether this complex type has simple contentbooleanisSimpleType()Test whether this SchemaType is a simple typejava.lang.Stringsubsumes(ComplexType sub)Test whether this complex type subsumes another complex type.
-
-
-
Method Detail
-
getInstance
public static AnyType getInstance()
Get the singular instance of this class- Returns:
- the singular object representing xs:anyType
-
getValidationStatus
public int getValidationStatus()
Get the validation status - always valid- Specified by:
getValidationStatusin interfaceSchemaComponent- Returns:
- one of the values
SchemaComponent.UNVALIDATED,SchemaComponent.VALIDATING,SchemaComponent.VALIDATED,SchemaComponent.INVALID,SchemaComponent.INCOMPLETE
-
getBaseType
public SchemaType getBaseType()
Get the base type- Specified by:
getBaseTypein interfaceSchemaType- Returns:
- null (this is the root of the type hierarchy)
-
getKnownBaseType
public SchemaType getKnownBaseType() throws java.lang.IllegalStateException
Returns the base type that this type inherits from. This method can be used to get the base type of a type that is known to be valid. If this type is a Simpletype that is a built in primitive type then null is returned.- Returns:
- the base type.
- Throws:
java.lang.IllegalStateException- if this type is not valid.
-
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.- Specified by:
getDerivationMethodin interfaceSchemaType- Returns:
- a numeric code representing the derivation method, for example
SchemaType.DERIVATION_RESTRICTION
-
allowsDerivation
public boolean allowsDerivation(int derivation)
Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property- Specified by:
allowsDerivationin interfaceSchemaType- Parameters:
derivation- the kind of derivation, for exampleSchemaType.DERIVATION_LIST- Returns:
- true if this kind of derivation is allowed
-
isAbstract
public boolean isAbstract()
Test whether this ComplexType has been marked as abstract.- Specified by:
isAbstractin interfaceComplexType- Returns:
- false: this class is not abstract.
-
isComplexType
public boolean isComplexType()
Test whether this SchemaType is a complex type- Specified by:
isComplexTypein interfaceSchemaType- Returns:
- true if this SchemaType is a complex type
-
isAnonymousType
public boolean isAnonymousType()
Test whether this is an anonymous type- Specified by:
isAnonymousTypein interfaceSchemaType- Returns:
- true if this SchemaType is an anonymous type
-
isSimpleType
public boolean isSimpleType()
Test whether this SchemaType is a simple type- Specified by:
isSimpleTypein interfaceSchemaType- Returns:
- true if this SchemaType is a simple type
-
isAtomicType
public boolean isAtomicType()
Test whether this SchemaType is an atomic type- Specified by:
isAtomicTypein interfaceSchemaType- Returns:
- true if this SchemaType is an atomic type
-
getBlock
public int getBlock()
Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such asSchemaType.DERIVATION_LISTandSchemaType.DERIVATION_EXTENSION- Specified by:
getBlockin interfaceSchemaType- Returns:
- the value of the 'block' attribute for this type
-
isComplexContent
public boolean isComplexContent()
Test whether this complex type has complex content- Specified by:
isComplexContentin interfaceComplexType- Returns:
- true: this complex type has complex content
-
isSimpleContent
public boolean isSimpleContent()
Test whether this complex type has simple content- Specified by:
isSimpleContentin interfaceComplexType- Returns:
- false: this complex type has complex content
-
isAllContent
public boolean isAllContent()
Test whether this complex type has "all" content, that is, a content model using an xs:all compositor- Specified by:
isAllContentin interfaceComplexType- Returns:
- false: this complex type does not use an "all" compositor
-
getSimpleContentType
public SimpleType getSimpleContentType()
For a complex type with simple content, return the simple type of the content. Otherwise, return null.- Specified by:
getSimpleContentTypein interfaceComplexType- Returns:
- null: this complex type does not have simple content
-
isRestricted
public boolean isRestricted()
Test whether this complex type is derived by restriction- Specified by:
isRestrictedin interfaceComplexType- Returns:
- false: this type is not a restriction
-
isEmptyContent
public boolean isEmptyContent()
Test whether the content type of this complex type is empty- Specified by:
isEmptyContentin interfaceComplexType- Returns:
- false: the content model is not empty
-
isEmptiable
public boolean isEmptiable()
Test whether the content model of this complexType allows empty content- Specified by:
isEmptiablein interfaceComplexType- Returns:
- true: the content is allowed to be empty
-
isMixedContent
public boolean isMixedContent()
Test whether this complex type allows mixed content- Specified by:
isMixedContentin interfaceComplexType- Returns:
- true: mixed content is allowed
-
getFingerprint
public int getFingerprint()
Get the fingerprint of the name of this type- Specified by:
getFingerprintin interfaceSchemaType- Returns:
- the fingerprint.
-
getNameCode
public int getNameCode()
Get the namecode of the name of this type. This includes the prefix from the original type declaration: in the case of built-in types, there may be a conventional prefix or there may be no prefix.- Specified by:
getNameCodein interfaceSchemaType
-
getDescription
public java.lang.String getDescription()
Get a description of this type for use in diagnostics- Specified by:
getDescriptionin interfaceSchemaType- Returns:
- the string "xs:anyType"
-
getDisplayName
public java.lang.String getDisplayName()
Get the display name of the type: that is, a lexical QName with an arbitrary prefix- Specified by:
getDisplayNamein interfaceSchemaType- Returns:
- a lexical QName identifying the type
-
isSameType
public boolean isSameType(SchemaType other)
Test whether this is the same type as another type. They are considered to be the same type if they are derived from the same type definition in the original XML representation (which can happen when there are multiple includes of the same file)- Specified by:
isSameTypein interfaceSchemaType
-
analyzeContentExpression
public 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.- Specified by:
analyzeContentExpressionin interfaceSchemaType- Parameters:
expression- the expression that delivers the contentkind- the node kind whose content is being delivered:Type.ELEMENT,Type.ATTRIBUTE, orType.DOCUMENTenv-
-
getTypedValue
public SequenceIterator getTypedValue(NodeInfo node)
Get the typed value of a node that is annotated with this schema type- Specified by:
getTypedValuein interfaceSchemaType- Parameters:
node- the node whose typed value is required- Returns:
- an iterator returning a single untyped atomic value, equivalent to the string value of the node. This follows the standard rules for elements with mixed content.
-
atomize
public Value atomize(NodeInfo node)
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 methodgetTypedValue(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:
atomizein interfaceSchemaType- Parameters:
node- the node whose typed value is required- Returns:
- the typed value.
- Since:
- 8.5
-
subsumes
public java.lang.String subsumes(ComplexType sub)
Test whether this complex type subsumes another complex type. The algorithm used is as published by Thompson and Tobin, XML Europe 2003.- Specified by:
subsumesin interfaceComplexType- Parameters:
sub- the other type (the type that is derived by restriction, validly or otherwise)- Returns:
- null indicating that this type does indeed subsume the other; or a string indicating why it doesn't.
-
checkTypeDerivationIsOK
public void checkTypeDerivationIsOK(SchemaType type, int block) throws SchemaException
Check that this type is validly derived from a given type- Specified by:
checkTypeDerivationIsOKin interfaceSchemaType- Parameters:
type- the type from which this type is derivedblock- the derivations that are blocked by the relevant element declaration- Throws:
SchemaException- if the derivation is not allowed
-
getElementParticleType
public SchemaType getElementParticleType(int fingerprint)
Find an element particle within this complex type definition having a given element name (identified by fingerprint), and return the schema type associated with that element particle. If there is no such particle, return null. If the fingerprint matches an element wildcard, return the type of the global element declaration with the given name if one exists, or AnyType if none exists and lax validation is permitted by the wildcard.- Specified by:
getElementParticleTypein interfaceComplexType- Parameters:
fingerprint- Identifies the name of the child element within this content model
-
getElementParticleCardinality
public int getElementParticleCardinality(int fingerprint)
Find an element particle within this complex type definition having a given element name (identified by fingerprint), and return the cardinality associated with that element particle, that is, the number of times the element can occur within this complex type. The value is one ofStaticProperty.EXACTLY_ONE,StaticProperty.ALLOWS_ZERO_OR_ONE,StaticProperty.ALLOWS_ZERO_OR_MORE,StaticProperty.ALLOWS_ONE_OR_MORE, If there is no such particle, return zero.- Specified by:
getElementParticleCardinalityin interfaceComplexType- Parameters:
fingerprint- Identifies the name of the child element within this content model
-
getAttributeUseType
public SchemaType getAttributeUseType(int fingerprint)
Find an attribute use within this complex type definition having a given attribute name (identified by fingerprint), and return the schema type associated with that attribute. If there is no such attribute use, return null. If the fingerprint matches an attribute wildcard, return the type of the global attribute declaration with the given name if one exists, or AnySimpleType if none exists and lax validation is permitted by the wildcard.- Specified by:
getAttributeUseTypein interfaceComplexType- Parameters:
fingerprint- Identifies the name of the child element within this content model
-
-