Package net.sf.saxon.type
Class AnyType
java.lang.Object
net.sf.saxon.type.AnyType
- All Implemented Interfaces:
Serializable
,ComplexType
,SchemaComponent
,SchemaType
This class has a singleton instance which represents the XML Schema built-in type xs:anyType,
also known as the urtype.
See XML Schema 1.1 Part 1 section 3.4.7
- See Also:
-
Field Summary
Fields inherited from interface net.sf.saxon.type.ComplexType
OPEN_CONTENT_ABSENT, OPEN_CONTENT_INTERLEAVE, OPEN_CONTENT_NONE, OPEN_CONTENT_SUFFIX, VARIETY_ELEMENT_ONLY, VARIETY_EMPTY, VARIETY_MIXED, VARIETY_SIMPLE
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
Modifier and TypeMethodDescriptionboolean
Return true if this type (or any known type derived from it by extension) allows the element to have one or more attributes.boolean
allowsDerivation
(int derivation) Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" propertyvoid
analyzeContentExpression
(Expression expression, int kind, StaticContext env) Analyze an expression to see whether the expression is capable of delivering a value of this type.Get the typed value of a node that is annotated with this schema type.void
checkTypeDerivationIsOK
(SchemaType type, int block) Check that this type is validly derived from a given typeboolean
Ask whether this type (or any known type derived from it by extension) allows the element to have children that match a wildcardvoid
gatherAllPermittedChildren
(IntHashSet children, boolean ignoreWildcards) Get a list of all the names of elements that can appear as children of an element having this complex type, as integer fingerprints.void
gatherAllPermittedDescendants
(IntHashSet descendants) Get a list of all the names of elements that can appear as descendants of an element having this complex type, as integer fingerprints.int
getAttributeUseCardinality
(int fingerprint) Find an attribute use within this complex type definition having a given attribute name (identified by fingerprint), and return the cardinality associated with that attribute, which will always be 0, 1, or 0-or-1.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.Get the base typeint
getBlock()
Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such asSchemaType.DERIVATION_LIST
andSchemaType.DERIVATION_EXTENSION
int
Gets the integer code of the derivation method used to derive this type from its parent.int
getDescendantElementCardinality
(int fingerprint) Assuming an element is a permitted descendant in the content model of this type, determine the cardinality of the element when it appears as a descendant.getDescendantElementType
(int fingerprint) Assuming an element is a permitted descendant in the content model of this type, determine the type of the element when it appears as a descendant.Get a description of this type for use in diagnosticsGet the display name of the type: that is, a lexical QName with an arbitrary prefixint
getElementParticleCardinality
(int fingerprint, boolean considerExtensions) 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.getElementParticleType
(int fingerprint, boolean considerExtensions) 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.int
Get the fingerprint of the name of this typestatic AnyType
Get the singular instance of this classReturns the base type that this type inherits from.getName()
Get the local name of this typeint
Get the namecode of the name of this type.int
Get the redefinition level.For a complex type with simple content, return the simple type of the content.Get the URI of the schema document containing the definition of this typeGet the target namespace of this typegetTypedValue
(NodeInfo node) Get the typed value of a node that is annotated with this schema typeint
Get the validation status - always validint
Get the variety of this complex type.boolean
Test whether this ComplexType has been marked as abstract.boolean
Test whether this complex type has "all" content, that is, a content model using an xs:all compositorboolean
Test whether this is an anonymous typeboolean
Test whether this SchemaType is an atomic typeboolean
Test whether this complex type has complex contentboolean
Test whether this SchemaType is a complex typeboolean
Test whether the content model of this complexType allows empty contentboolean
Test whether the content type of this complex type is emptyboolean
Ask whether this type is an IDREF or IDREFS type.boolean
isIdType()
Ask whether this type is an ID type.boolean
Test whether this complex type allows mixed contentboolean
Test whether this complex type is derived by restrictionboolean
isSameType
(SchemaType other) Test whether this is the same type as another type.boolean
Test whether this complex type has simple contentboolean
Test whether this SchemaType is a simple type
-
Method Details
-
getInstance
Get the singular instance of this class- Returns:
- the singular object representing xs:anyType
-
getName
Get the local name of this type- Specified by:
getName
in interfaceSchemaType
- Returns:
- the local name of this type definition, if it has one. Return null in the case of an anonymous type.
-
getTargetNamespace
Get the target namespace of this type- Specified by:
getTargetNamespace
in interfaceSchemaType
- Returns:
- the target namespace of this type definition, if it has one. Return null in the case of an anonymous type, and in the case of a global type defined in a no-namespace schema.
-
getVariety
public int getVariety()Get the variety of this complex type. This will be one of the valuesComplexType.VARIETY_EMPTY
,ComplexType.VARIETY_MIXED
,ComplexType.VARIETY_SIMPLE
, orComplexType.VARIETY_ELEMENT_ONLY
- Specified by:
getVariety
in interfaceComplexType
-
getValidationStatus
public int getValidationStatus()Get the validation status - always valid- Specified by:
getValidationStatus
in interfaceSchemaComponent
- Returns:
- one of the values
SchemaComponent.UNVALIDATED
,SchemaComponent.VALIDATING
,SchemaComponent.VALIDATED
,SchemaComponent.INVALID
,SchemaComponent.INCOMPLETE
-
getRedefinitionLevel
public int getRedefinitionLevel()Get the redefinition level. This is zero for a component that has not been redefined; for a redefinition of a level-0 component, it is 1; for a redefinition of a level-N component, it is N+1. This concept is used to support the notion of "pervasive" redefinition: if a component is redefined at several levels, the top level wins, but it is an error to have two versions of the component at the same redefinition level.- Specified by:
getRedefinitionLevel
in interfaceSchemaComponent
- Returns:
- the redefinition level
-
getBaseType
Get the base type- Specified by:
getBaseType
in interfaceSchemaType
- Returns:
- null (this is the root of the type hierarchy)
-
getKnownBaseType
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:
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:
getDerivationMethod
in 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:
allowsDerivation
in 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:
isAbstract
in interfaceComplexType
- Returns:
- false: this class is not abstract.
-
isComplexType
public boolean isComplexType()Test whether this SchemaType is a complex type- Specified by:
isComplexType
in interfaceSchemaType
- Returns:
- true if this SchemaType is a complex type
-
isAnonymousType
public boolean isAnonymousType()Test whether this is an anonymous type- Specified by:
isAnonymousType
in interfaceSchemaType
- Returns:
- true if this SchemaType is an anonymous type
-
isSimpleType
public boolean isSimpleType()Test whether this SchemaType is a simple type- Specified by:
isSimpleType
in interfaceSchemaType
- Returns:
- true if this SchemaType is a simple type
-
isAtomicType
public boolean isAtomicType()Test whether this SchemaType is an atomic type- Specified by:
isAtomicType
in interfaceSchemaType
- Returns:
- true if this SchemaType is an atomic type
-
isIdType
public boolean isIdType()Ask 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, its typed value must be a *single* atomic value of type ID; the type of the node, however, can still allow a list.- Specified by:
isIdType
in interfaceSchemaType
- Returns:
- true if this type is an ID type
-
isIdRefType
public boolean isIdRefType()Ask 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:
isIdRefType
in interfaceSchemaType
- Returns:
- true if this type is an IDREF 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_LIST
andSchemaType.DERIVATION_EXTENSION
- Specified by:
getBlock
in 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:
isComplexContent
in interfaceComplexType
- Returns:
- true: this complex type has complex content
-
isSimpleContent
public boolean isSimpleContent()Test whether this complex type has simple content- Specified by:
isSimpleContent
in 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:
isAllContent
in interfaceComplexType
- Returns:
- false: this complex type does not use an "all" compositor
-
getSimpleContentType
For a complex type with simple content, return the simple type of the content. Otherwise, return null.- Specified by:
getSimpleContentType
in 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:
isRestricted
in 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:
isEmptyContent
in 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:
isEmptiable
in interfaceComplexType
- Returns:
- true: the content is allowed to be empty
-
isMixedContent
public boolean isMixedContent()Test whether this complex type allows mixed content- Specified by:
isMixedContent
in interfaceComplexType
- Returns:
- true: mixed content is allowed
-
getFingerprint
public int getFingerprint()Get the fingerprint of the name of this type- Specified by:
getFingerprint
in 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:
getNameCode
in interfaceSchemaType
- Returns:
- the namecode. Returns an invented namecode for an anonymous type.
-
getDescription
Get a description of this type for use in diagnostics- Specified by:
getDescription
in interfaceSchemaType
- Returns:
- the string "xs:anyType"
-
getDisplayName
Get the display name of the type: that is, a lexical QName with an arbitrary prefix- Specified by:
getDisplayName
in interfaceSchemaType
- Returns:
- a lexical QName identifying the type
-
getSystemId
Get the URI of the schema document containing the definition of this type- Specified by:
getSystemId
in interfaceSchemaType
- Returns:
- null for a built-in type
-
isSameType
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:
isSameType
in interfaceSchemaType
- Parameters:
other
- the other type- Returns:
- true if this is the same type as other
-
analyzeContentExpression
Analyze an expression to see whether the expression is capable of delivering a value of this type.- Specified by:
analyzeContentExpression
in interfaceSchemaType
- Parameters:
expression
- the expression that delivers the contentkind
- the node kind whose content is being delivered:Type.ELEMENT
,Type.ATTRIBUTE
, orType.DOCUMENT
env
-
-
getTypedValue
Get the typed value of a node that is annotated with this schema type- Specified by:
getTypedValue
in 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
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:
atomize
in interfaceSchemaType
- Parameters:
node
- the node whose typed value is required- Returns:
- the typed value.
- Since:
- 8.5
-
checkTypeDerivationIsOK
Check that this type is validly derived from a given type- Specified by:
checkTypeDerivationIsOK
in 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
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:
getElementParticleType
in interfaceComplexType
- Parameters:
fingerprint
- Identifies the name of the child element within this content modelconsiderExtensions
-- Returns:
- the schema type associated with the child element particle with the given name. If there is no such particle, return null.
-
getElementParticleCardinality
public int getElementParticleCardinality(int fingerprint, boolean considerExtensions) 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:
getElementParticleCardinality
in interfaceComplexType
- Parameters:
fingerprint
- Identifies the name of the child element within this content modelconsiderExtensions
-- Returns:
- the cardinality associated with the child element particle with the given name.
If there is no such particle, return
StaticProperty.EMPTY
.
-
getAttributeUseType
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:
getAttributeUseType
in interfaceComplexType
- Parameters:
fingerprint
- Identifies the name of the child element within this content model- Returns:
- the schema type associated with the attribute use identified by the fingerprint. If there is no such attribute use, return null.
-
getAttributeUseCardinality
Find an attribute use within this complex type definition having a given attribute name (identified by fingerprint), and return the cardinality associated with that attribute, which will always be 0, 1, or 0-or-1. 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. If there are types derived from this type by extension, search those too.- Specified by:
getAttributeUseCardinality
in interfaceComplexType
- Parameters:
fingerprint
- Identifies the name of the child element within this content model- Returns:
- the schema type associated with the attribute use identified by the fingerprint. If there is no such attribute use, return null.
- Throws:
SchemaException
-
allowsAttributes
public boolean allowsAttributes()Return true if this type (or any known type derived from it by extension) allows the element to have one or more attributes.- Specified by:
allowsAttributes
in interfaceComplexType
- Returns:
- true if attributes are allowed
-
gatherAllPermittedChildren
public void gatherAllPermittedChildren(IntHashSet children, boolean ignoreWildcards) throws SchemaException Get a list of all the names of elements that can appear as children of an element having this complex type, as integer fingerprints. If the list is unbounded (because of wildcards or the use of xs:anyType), return null.- Specified by:
gatherAllPermittedChildren
in interfaceComplexType
- Parameters:
children
- an integer set, initially empty, which on return will hold the fingerprints of all permitted child elements; if the result contains the value -1, this indicates that it is not possible to enumerate all the children, typically because of wildcards. In this case the other contents of the set shouldignoreWildcards
-- Throws:
SchemaException
-
gatherAllPermittedDescendants
Get a list of all the names of elements that can appear as descendants of an element having this complex type, as integer fingerprints. If the list is unbounded (because of wildcards or the use of xs:anyType), return null.- Specified by:
gatherAllPermittedDescendants
in interfaceComplexType
- Parameters:
descendants
- an integer set, initially empty, which on return will hold the fingerprints of all permitted descendant elements; if the result contains the value -1, this indicates that it is not possible to enumerate all the descendants, typically because of wildcards. In this case the other contents of the set should be ignored.- Throws:
SchemaException
-
getDescendantElementType
Assuming an element is a permitted descendant in the content model of this type, determine the type of the element when it appears as a descendant. If it appears with more than one type, return xs:anyType.- Specified by:
getDescendantElementType
in interfaceComplexType
- Parameters:
fingerprint
- the name of the required descendant element- Returns:
- the type of the descendant element; null if the element cannot appear as a descendant; anyType if it can appear with several different types
- Throws:
SchemaException
-
getDescendantElementCardinality
Assuming an element is a permitted descendant in the content model of this type, determine the cardinality of the element when it appears as a descendant.- Specified by:
getDescendantElementCardinality
in interfaceComplexType
- Parameters:
fingerprint
- the name of the required descendant element- Returns:
- the cardinality of the descendant element within this complex type
- Throws:
SchemaException
-
containsElementWildcard
public boolean containsElementWildcard()Ask whether this type (or any known type derived from it by extension) allows the element to have children that match a wildcard- Specified by:
containsElementWildcard
in interfaceComplexType
- Returns:
- true if the content model of this type, or its extensions, contains an element wildcard
-