Package com.saxonica.ee.schema
Class CompiledComplexType
java.lang.Object
com.saxonica.ee.schema.CompiledComplexType
This class contains information obtained by compiling a
UserComplexType in the context
of a particular schema. The same UserComplexType might have different compiled
representations in different schemas, because the compiled form takes into account
information such as substitution group membership that can vary from one schema
to another-
Constructor Summary
ConstructorsConstructorDescriptionCompiledComplexType(PreparedSchema schema, UserComplexType type) CompiledComplexType(PreparedSchema schema, UserComplexType type, FiniteStateMachine fsm) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAsk whether this type (or any known type derived from it by extension) allows the element to have one or more attributes.voidanalyzeContentExpression(Expression expression, int kind, Schema schema) Analyze an XPath expression to see whether the expression is capable of delivering a value of this type.voidbuildValidationMachinery(SchemaCompiler compiler, PreparedSchema schema) Compile the finite-state machine for validating instances against this typevoidCancel validation and compilation: this happens when the complex type is redefinedbooleanAsk whether this type (or any known type derived from it by extension) allows the element to have children that match a wildcardvoidgatherAllPermittedChildren(PreparedSchema schema, 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.voidgatherAllPermittedDescendants(PreparedSchema schema, 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.intgetAttributeUseCardinality(StructuredQName attributeName, PreparedSchema schema) 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(StructuredQName attributeName, PreparedSchema schema) 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 context-determined type for a given attribute.Get the context-determined type for a given child element.intgetDescendantElementCardinality(PreparedSchema schema, int elementFingerprint) 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(PreparedSchema schema, int elementName) 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.intgetElementParticleCardinality(int elementName, PreparedSchema schema, 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 elementName, PreparedSchema schema, 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.Get the finite state machine used for validation against this typeGet the initial dynamic state of the finite state machine used for validating against this type.getType()protected voidmakeAutomaton(SchemaCompiler compiler) voidBuild the context-determined type map for attributesvoidBuild the context-determined type map for elementsvoidrecompile(SchemaCompiler compiler) Recompile the complex type when new members are added to the substitution group of an elementvoidsetFiniteStateMachine(FiniteStateMachine machine) Set the finite state machine.
-
Constructor Details
-
CompiledComplexType
-
CompiledComplexType
-
-
Method Details
-
getConfiguration
-
getType
-
getSchema
-
getElementParticleType
public SchemaType getElementParticleType(int elementName, PreparedSchema schema, boolean considerExtensions) throws MissingComponentException 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.- Parameters:
elementName- Identifies the name of the child element within this content modelschema-considerExtensions- if true, and if the element particle is not defined within this type itself, try to find it within the types derived by extension from this type, and/or within the open content model permitted by the type. If there is one extension that defines the particle, return- Throws:
MissingComponentException
-
getElementParticleCardinality
public int getElementParticleCardinality(int elementName, PreparedSchema schema, boolean considerExtensions) throws MissingComponentException 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, returnStaticProperty.EMPTY. The method also searches for wildcard particles, element particles in extension types, and wildcards defined as open content.- Parameters:
elementName- Identifies the name of the child element within this content modelschema-considerExtensions- if true, types derived by extension from this type should be taken into account- Returns:
- the cardinality of the requested element within this complex type
- Throws:
MissingComponentException
-
gatherAllPermittedChildren
public void gatherAllPermittedChildren(PreparedSchema schema, 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. The result includes elements defined in types that are defined by extension from this type.- Parameters:
schema-children- a set, initially empty, which on return will hold the names of all permitted child elements; if the result contains the value XS_INVALID_NAME, 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 should be ignoredignoreWildcards- if set to true, wildcards are ignored; only the elements that match explicit- Throws:
SchemaException
-
gatherAllPermittedDescendants
public void gatherAllPermittedDescendants(PreparedSchema schema, IntHashSet descendants) throws SchemaException 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. The result includes elements defined in types that are defined by extension from this type or other types processed- Parameters:
schema-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
public SchemaType getDescendantElementType(PreparedSchema schema, int elementName) throws SchemaException 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.- Parameters:
schema- the schema to be searchedelementName- 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
public int getDescendantElementCardinality(PreparedSchema schema, int elementFingerprint) throws SchemaException 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.- Parameters:
schema- the schema to be searchedelementFingerprint- the name of the required descendant element- Returns:
- the cardinality of the descendant element within this complex type
- Throws:
SchemaException
-
getAttributeUseType
public SimpleType getAttributeUseType(StructuredQName attributeName, PreparedSchema schema) throws SchemaException 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.- Parameters:
attributeName- Identifies the name of the required attribute use within this content modelschema- the schema to be searched- Throws:
SchemaException
-
getAttributeUseCardinality
public int getAttributeUseCardinality(StructuredQName attributeName, PreparedSchema schema) throws SchemaException 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 0. If the fingerprint matches an attribute wildcard, return 0-or-1.If there are types derived from this type by extension, search those too.
- Parameters:
attributeName- Identifies the name of the required attribute within this content modelschema-- Returns:
- the cardinality associated with the attribute use identified by the fingerprint. If the attribute is optional but either the attribute use or the corresponding attribute declaration defines a default or fixed value, then it is treated as optional (zero-or-one), because we don't know whether fixed/default attribute values are being reported to the application or not: see bug 3072.
- Throws:
SchemaException
-
allowsAttributes
Ask whether this type (or any known type derived from it by extension) allows the element to have one or more attributes.- Returns:
- true if attributes (other than the standard xsi: attributes) are allowed. The value false indicates that only the standard attributes in the xsi namespace are permitted.
- Throws:
MissingComponentException
-
containsElementWildcard
Ask whether this type (or any known type derived from it by extension) allows the element to have children that match a wildcard- Returns:
- true if the content model of this type, or its extensions, contains an element wildcard
- Throws:
MissingComponentException
-
makeContextDeterminedTypeMapForElements
Build the context-determined type map for elements- Throws:
SchemaException- if an error is encountered
-
getContextDeterminedTypeForElement
Get the context-determined type for a given child element. Note that this does not consider types derived from this one by extension.- Parameters:
fp- the child element name- Returns:
- the context-determined type for this element, if there is one, or null otherwise
-
makeContextDeterminedTypeMapForAttributes
Build the context-determined type map for attributes- Throws:
SchemaException- if an error is encountered
-
getContextDeterminedTypeForAttribute
Get the context-determined type for a given attribute. Note that this does not consider types derived from this one by extension.- Parameters:
fp- the attribute name- Returns:
- the context-determined type for this attribute, if there is one, or null otherwise
-
analyzeContentExpression
public void analyzeContentExpression(Expression expression, int kind, Schema schema) throws XPathException Analyze an XPath expression to see whether the expression is capable of delivering a value of this type.- Parameters:
expression- the expression that delivers the content. If this is a Block, the sequence of instructions within the block is checked by this method, and the individual instructions are checked by a callback; in other cases the method calls expression.checkPermittedContents() which may pass the analysis onto other expressions.kind- the node kind whose content is being delivered:Type.ELEMENT,Type.ATTRIBUTE, orType.DOCUMENTschema-- Throws:
XPathException- if the expression will never deliver a value of the correct type (that is, of this type)
-
setFiniteStateMachine
Set the finite state machine. Used when restoring a serialized component model- Parameters:
machine- the FSM for this complex type
-
buildValidationMachinery
public void buildValidationMachinery(SchemaCompiler compiler, PreparedSchema schema) throws SchemaException Compile the finite-state machine for validating instances against this type- Parameters:
compiler- used for error reporting- Throws:
SchemaException- to indicate an invalid schema
-
makeAutomaton
- Throws:
SchemaException
-
recompile
Recompile the complex type when new members are added to the substitution group of an element- Parameters:
compiler- user for error reporting- Throws:
SchemaException- if an error is encountered
-
cancelValidation
public void cancelValidation()Cancel validation and compilation: this happens when the complex type is redefined -
getFiniteStateMachine
Get the finite state machine used for validation against this type- Returns:
- the finite state machine. May be null if this type does not have a complex content
model, or has an
<all>model
-
getInitialState
Get the initial dynamic state of the finite state machine used for validating against this type.- Returns:
- the initial state of the machine. If this is null, then the complex type has an empty content model.
-