Package com.saxonica.ee.schema
Class UserComplexType
- java.lang.Object
-
- com.saxonica.ee.schema.SchemaStructure
-
- com.saxonica.ee.schema.UserDefinedType
-
- com.saxonica.ee.schema.UserComplexType
-
- All Implemented Interfaces:
SerializableSchemaComponent
,UserSchemaComponent
,javax.xml.transform.SourceLocator
,Location
,ComplexType
,SchemaComponent
,SchemaType
,org.xml.sax.Locator
public class UserComplexType extends UserDefinedType implements ComplexType, UserSchemaComponent, SerializableSchemaComponent
A user-defined complex type (that is, any complex type other than xs:anyType)
-
-
Field Summary
-
Fields inherited from class com.saxonica.ee.schema.UserDefinedType
extendedTypes, finalProhibitions
-
-
Constructor Summary
Constructors Constructor Description UserComplexType(EnterpriseConfiguration config, javax.xml.transform.SourceLocator locator)
Creates a new user-defined Complextype
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAssertion(Assertion assertion)
Add an assertion to this complex typevoid
addAttributeGroupReference(AttributeGroupReference attrGroupRef)
Adds the given AttributeGroupReference to this UserComplexTypevoid
addAttributeUse(AttributeUse use)
Adds the given AttributeUse to this UserComplexType.void
addNonInheritedAttributeUse(AttributeUse use)
Add an attribute use to the final (combined) content model for this complex type.boolean
allowsAttributes()
Ask whether this type (or any known type derived from it by extension) allows the element to have one or more attributes.void
analyzeContentExpression(Expression expression, int kind)
Analyze an expression to see whether the expression is capable of delivering a value of this type.AtomicSequence
atomize(NodeInfo node)
Get the typed value of a node that is annotated with this schema type.void
cancelValidation()
Cancel validation and compilation: this happens when the complex type is redefinedstatic void
checkTypeDerivation(ComplexType derived, SchemaType base, int block)
Check that a type is validly derived from a given type.void
compile(SchemaCompiler compiler)
Compile the finite-state machine for validating instances against this typeboolean
computeIsAllContent()
Compute whether this complex type has a content model defined by an xs:all compositor (after simplification to remove pointless particles)boolean
containsElementWildcard()
Ask whether this type (or any known type derived from it by extension) allows the element to have children that match a wildcardvoid
elaborate(SchemaCompiler compiler)
Elaborate the schema component: after reloading a serialized schema component model, this expands the component with derived information needed during validation episodes.protected static java.lang.String
elementParticleMatches(ElementDecl base, ElementDecl sub, SchemaCompiler compiler)
Determine whether one element term matches another.boolean
fixup(SchemaCompiler compiler)
Check references from this component to other componentsvoid
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.ModelGroupParticle
getAllCompositor()
For a complex type with "all" content, get the "all" model group.java.util.Set<Assertion>
getAssertions()
Get the assertions defined on this complex typejava.util.Set<Assertion>
getAssertions(Sweep sweep)
Get the assertions defined on this complex type that have a given streaming sweepAttributeGroupDecl
getAttributeGroup()
Returns the attribute group containing details of all the attributes defined for this complex type.int
getAttributeUseCardinality(StructuredQName attributeName)
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.SimpleType
getAttributeUseType(StructuredQName attributeName)
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.int
getBlock()
Returns the value of the 'block' attribute for this elementAttributeGroupDecl
getCombinedAttributeGroup()
Returns the attribute group containing details of all the attributes defined for this complex type.Function
getComponentAsFunction()
Get the schema component in the form of a function item.static Function
getComponentAsFunction(ComplexType type)
SimpleType
getContextDeterminedTypeForAttribute(StructuredQName fp)
Get the context-determined type for a given attribute.SchemaType
getContextDeterminedTypeForElement(StructuredQName fp)
Get the context-determined type for a given child element.int
getDescendantElementCardinality(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.SchemaType
getDescendantElementType(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.int
getElementParticleCardinality(int elementName, 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.SchemaType
getElementParticleType(int elementName, 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.java.lang.String
getEQName()
Get the name of this type as an EQName, that is, a string in the format Q{uri}local.FiniteStateMachine
getFiniteStateMachine()
Get the finite state machine used for validation against this typeState
getInitialState()
Get the initial dynamic state of the finite state machine used for validating against this type.int
getLanguageVersion()
Get the XML Schema language versionOpenContentVariety
getOpenContentMode()
Ask whether open content permitted on this complex type is interleaved or suffixed.java.lang.String
getOpenContentModeString()
Wildcard
getOpenContentWildcard()
Get the open content wildcard for this complex type.Particle
getParticle()
Get the (extended) particle representing the content model of this complex type.SimpleType
getSimpleContentType()
For a complex type with simple content, return the simple type of the content.TypeReference
getSimpleContentTypeReference()
Get the reference to the simple content typeComplexVariety
getVariety()
Get the variety of this complex type.boolean
hasAssertions()
Test whether there are any assertions defined on this complex typeboolean
isAbstract()
Returns true if this UserComplexType has been marked as Abstract.boolean
isAllContent()
Test whether this complex type has "all" content, that is, a content model using an xs:all compositorboolean
isAtomicType()
Ask whether this SchemaType is an atomic typeboolean
isComplexContent()
Returns true if this complexType has complex content: that is, if its {content type} is anything other than a simple type definition.boolean
isEmptiable()
Test whether the content model of this complexType allows empty contentboolean
isEmptyContent()
Ask whether the contentType of this complexType is emptyboolean
isIdRefType()
Ask whether this type is an IDREF or IDREFS type.boolean
isIdType()
Ask whether this type is an ID type.boolean
isMixedContent()
Ask whether this complex type allows mixed contentboolean
isRestricted()
Ask whether this complexType is a restrictionboolean
isSimpleContent()
Returns true if this complexType has simple content; that is, if its {content type} is a simple type definition and its {variety} is simple.boolean
isSimpleType()
Ask whether this SchemaType is a simple typejava.lang.String
isSubsumedBy(ComplexType base, SchemaCompiler compiler)
Test whether this complex type is subsumed by another complex type.boolean
isValidRestriction(SchemaType base, SchemaCompiler compiler)
Determine whether this type is a valid restriction of another typevoid
lookForCycles(java.util.Stack<SchemaComponent> references, SchemaCompiler compiler)
This method is called to look for cycles.protected void
makeAutomaton(SchemaCompiler compiler)
void
makeContextDeterminedTypeMapForAttributes()
Build the context-determined type map for attributesvoid
makeContextDeterminedTypeMapForElements()
Build the context-determined type map for elementsParticle
makeExtendedParticle(SchemaCompiler compiler)
Get the particle corresponding to this UserComplexType, combining it with the content model of the base type if this type is derived by extension.void
recompile(SchemaCompiler compiler)
Recompile the complex type when new members are added to the substitution group of an elementvoid
serialize(SchemaModelSerializer serializer)
Serialize the schema componentvoid
setAbstract(boolean isAbstract)
Sets whether or not this UserComplexType should be abstract.void
setAnyAttribute(AttributeWildcard wildcard)
Sets the wildcard (anyAttribute) of the complexType.void
setBlock(int block)
Sets the value of the 'block' attribute for this UserComplexType.void
setEmptyCombinedAttributeGroup()
Set the combined attribute group to an empty set of attributes.void
setFiniteStateMachine(FiniteStateMachine machine)
Set the finite state machine.void
setNonInheritedAnyAttribute(AttributeWildcard wildcard)
Sets the wildcard (anyAttribute) of the complexType on both the locally-declared and the combined attribute groups.void
setOpenContentWildcard(Wildcard wildcard, java.lang.String mode, boolean appliesToEmpty)
Set the open content details for this complex typevoid
setParticle(Particle particle)
Set the particle representing the content model of this complex typevoid
setRestriction(boolean restricted)
Set whether or not this complexType is a restrictionvoid
setSaxonDebug(boolean debug)
Set Saxon debugging on or offvoid
setSimpleContentTypeReference(TypeReference ref)
For a complex type with simple content, set a reference to the simple type of the contentvoid
setVariety(ComplexVariety variety)
Set the variety of this complex typejava.lang.String
subsumesAll(UserComplexType sub, SchemaCompiler compiler)
Test whether the particle of this complex type subsumes a complex type defined using xs:allboolean
validate(SchemaCompiler compiler)
Checks the validity of this UserComplexType definition.-
Methods inherited from class com.saxonica.ee.schema.UserDefinedType
allowsDerivation, checkTypeDerivationIsOK, containingDeclarationIsElement, getBaseType, getBaseTypeFingerprint, getBaseTypeReference, getContainingDeclarationName, getDerivationMethod, getDescription, getDisplayName, getExtensionTypes, getFinalProhibitions, getFingerprint, getName, getNamePool, getStructuredQName, getTargetNamespace, getTypeName, isAnonymousType, isComplexType, isSameType, isSameURI, registerExtensionType, setBaseTypeReference, setContainingDeclaration, setDerivationMethod, setDerivationMethodName, setExtendedTypes, setFinalProhibitions, setTypeName, toString
-
Methods inherited from class com.saxonica.ee.schema.SchemaStructure
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.SchemaComponent
getRedefinitionLevel, getValidationStatus
-
Methods inherited from interface net.sf.saxon.type.SchemaType
allowsDerivation, checkTypeDerivationIsOK, getBaseType, getDerivationMethod, getDescription, getDisplayName, getFinalProhibitions, getFingerprint, getName, getStructuredQName, getSystemId, getTargetNamespace, isAnonymousType, isComplexType, isSameType
-
-
-
-
Constructor Detail
-
UserComplexType
public UserComplexType(EnterpriseConfiguration config, javax.xml.transform.SourceLocator locator)
Creates a new user-defined Complextype- Parameters:
config
- the Configuration to which this user-defined complex type belongslocator
- the location of this complex type within a schema document
-
-
Method Detail
-
getVariety
public ComplexVariety getVariety()
Get the variety of this complex type. This will be one of the valuesComplexVariety.EMPTY
,ComplexVariety.MIXED
,ComplexVariety.SIMPLE
, orComplexVariety.ELEMENT_ONLY
- Specified by:
getVariety
in interfaceComplexType
- Returns:
- the variety of this complex type
-
getEQName
public java.lang.String getEQName()
Get the name of this type as an EQName, that is, a string in the format Q{uri}local.- Specified by:
getEQName
in interfaceSchemaType
- Overrides:
getEQName
in classUserDefinedType
- Returns:
- an EQName identifying the type. In the case of an anonymous type, an internally-generated name is returned
-
setSaxonDebug
public void setSaxonDebug(boolean debug)
Set Saxon debugging on or off- Parameters:
debug
- true to switch debugging on; false to switch it off
-
getLanguageVersion
public int getLanguageVersion()
Get the XML Schema language version- Returns:
Configuration.XSD10
orConfiguration.XSD11
-
setFiniteStateMachine
public void setFiniteStateMachine(FiniteStateMachine machine)
Set the finite state machine. Used when restoring a serialized component model- Parameters:
machine
- the FSM for this complex type
-
addAttributeUse
public void addAttributeUse(AttributeUse use)
Adds the given AttributeUse to this UserComplexType. Doesn't throw an error if it's a duplicate: this is left to be checked at validation time- Parameters:
use
- the AttributeUse to add to this UserComplexType
-
setEmptyCombinedAttributeGroup
public void setEmptyCombinedAttributeGroup()
Set the combined attribute group to an empty set of attributes. Used when rebuilding a complex type from a saved SCM file
-
addNonInheritedAttributeUse
public void addNonInheritedAttributeUse(AttributeUse use)
Add an attribute use to the final (combined) content model for this complex type. This is used when rebuilding a complex type from a saved SCM file; the difference is that in this case, all required attributes are added explicitly, and none are inherited from the base type.- Parameters:
use
- the AttributeUse to add to this UserComplexType
-
addAttributeGroupReference
public void addAttributeGroupReference(AttributeGroupReference attrGroupRef)
Adds the given AttributeGroupReference to this UserComplexType- Parameters:
attrGroupRef
- the AttributeGroupReference to add to this UserComplexType
-
getAttributeGroup
public AttributeGroupDecl getAttributeGroup()
Returns the attribute group containing details of all the attributes defined for this complex type. This method does not include the attributes defined on the base type: for that, usegetCombinedAttributeGroup()
- Returns:
- an AttributeGroup holding the attribute details
-
getCombinedAttributeGroup
public AttributeGroupDecl getCombinedAttributeGroup()
Returns the attribute group containing details of all the attributes defined for this complex type. This method also includes the attributes defined on the base type, and excludes any prohibited attributes- Returns:
- an AttributeGroup holding the attribute details
-
getBlock
public int getBlock()
Returns the value of the 'block' attribute for this element- Specified by:
getBlock
in interfaceSchemaType
- Overrides:
getBlock
in classUserDefinedType
- Returns:
- the value of the 'block' attribute for this element
-
isAbstract
public boolean isAbstract()
Returns true if this UserComplexType has been marked as Abstract.- Specified by:
isAbstract
in interfaceComplexType
- Returns:
- true if this UserComplexType is "abstract".
-
isComplexContent
public boolean isComplexContent()
Returns true if this complexType has complex content: that is, if its {content type} is anything other than a simple type definition.- Specified by:
isComplexContent
in interfaceComplexType
- Returns:
- true if this complexType has complex content
-
isSimpleContent
public boolean isSimpleContent()
Returns true if this complexType has simple content; that is, if its {content type} is a simple type definition and its {variety} is simple.- Specified by:
isSimpleContent
in interfaceComplexType
- Returns:
- true if this complexType has simple 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:
- true if the type has an "all" content model
-
computeIsAllContent
public boolean computeIsAllContent() throws SchemaException
Compute whether this complex type has a content model defined by an xs:all compositor (after simplification to remove pointless particles)- Returns:
- true if the content model of the complex type is "all"
- Throws:
SchemaException
- if an error is found in the schema
-
getAllCompositor
public ModelGroupParticle getAllCompositor() throws MissingComponentException
For a complex type with "all" content, get the "all" model group. This method is always applied to the simplified content model (after removal of pointless particles)- Returns:
- the "all" particle if there is one, or null otherwise.
- Throws:
MissingComponentException
-
setSimpleContentTypeReference
public void setSimpleContentTypeReference(TypeReference ref)
For a complex type with simple content, set a reference to the simple type of the content- Parameters:
ref
- a reference to a simple type
-
getSimpleContentTypeReference
public TypeReference getSimpleContentTypeReference()
Get the reference to the simple content type- Returns:
- a reference to a simple type, or null if the type is not a complex type with simple content
-
getSimpleContentType
public SimpleType getSimpleContentType() throws MissingComponentException
For a complex type with simple content, return the simple type of the content. Otherwise, return null.- Specified by:
getSimpleContentType
in interfaceComplexType
- Returns:
- For a complex type with simple content, returns the simple type of the content. Otherwise, returns null.
- Throws:
MissingComponentException
-
isRestricted
public boolean isRestricted()
Ask whether this complexType is a restriction- Specified by:
isRestricted
in interfaceComplexType
- Returns:
- true if this complexType is a restriction
-
isEmptyContent
public boolean isEmptyContent()
Ask whether the contentType of this complexType is empty- Specified by:
isEmptyContent
in interfaceComplexType
- Returns:
- true if the content model is defined as empty
-
isMixedContent
public boolean isMixedContent()
Ask whether this complex type allows mixed content- Specified by:
isMixedContent
in interfaceComplexType
- Returns:
- true, if and only if this type allows mixed content
-
isSimpleType
public boolean isSimpleType()
Ask 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()
Ask 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() throws MissingComponentException
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
- Throws:
MissingComponentException
-
isIdRefType
public boolean isIdRefType() throws MissingComponentException
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
- Throws:
MissingComponentException
-
getOpenContentWildcard
public Wildcard getOpenContentWildcard()
Get the open content wildcard for this complex type.- Returns:
- the open content wildcard, or null if open content is not allowed for this complex type.
-
getOpenContentMode
public OpenContentVariety getOpenContentMode()
Ask whether open content permitted on this complex type is interleaved or suffixed.- Returns:
- the open content mode:
OpenContentVariety.NONE
,OpenContentVariety.ABSENT
,OpenContentVariety.INTERLEAVE
, orOpenContentVariety.SUFFIX
-
getOpenContentModeString
public java.lang.String getOpenContentModeString()
-
setAbstract
public void setAbstract(boolean isAbstract)
Sets whether or not this UserComplexType should be abstract.- Parameters:
isAbstract
- a boolean that when true makes this UserComplexType abstract.
-
setAnyAttribute
public void setAnyAttribute(AttributeWildcard wildcard)
Sets the wildcard (anyAttribute) of the complexType. It is the caller's responsibility to check that there can be at most one attribute wildcard in a complex type definition.- Parameters:
wildcard
- the attribute wildcard
-
setNonInheritedAnyAttribute
public void setNonInheritedAnyAttribute(AttributeWildcard wildcard)
Sets the wildcard (anyAttribute) of the complexType on both the locally-declared and the combined attribute groups. Used when reloading the complex type from an SCM file.- Parameters:
wildcard
- the attribute wildcard
-
setBlock
public void setBlock(int block)
Sets the value of the 'block' attribute for this UserComplexType.- Parameters:
block
- the value of the block attribute for this UserComplexType definition, as a bit-significant integer.
-
setVariety
public void setVariety(ComplexVariety variety)
Set the variety of this complex type- Parameters:
variety
- the variety: one of of the valuesComplexVariety.EMPTY
,ComplexVariety.MIXED
,ComplexVariety.SIMPLE
, orComplexVariety.ELEMENT_ONLY
-
setRestriction
public void setRestriction(boolean restricted)
Set whether or not this complexType is a restriction- Parameters:
restricted
- true if this complexType is a restriction
-
setParticle
public void setParticle(Particle particle)
Set the particle representing the content model of this complex type- Parameters:
particle
- the Particle to add
-
setOpenContentWildcard
public void setOpenContentWildcard(Wildcard wildcard, java.lang.String mode, boolean appliesToEmpty)
Set the open content details for this complex type- Parameters:
wildcard
- the open content wildcard, defined either by the<openContent>
or<defaultOpenContent>
elementsmode
- the open content mode. This must be one of "interleave" or "suffix"appliesToEmpty
- set to true if this open content applies even when the type would otherwise have an empty content model
-
addAssertion
public void addAssertion(Assertion assertion)
Add an assertion to this complex type- Parameters:
assertion
- the assertion to be added
-
hasAssertions
public boolean hasAssertions()
Test whether there are any assertions defined on this complex type- Specified by:
hasAssertions
in interfaceComplexType
- Returns:
- true if there are any assertions
-
getAssertions
public java.util.Set<Assertion> getAssertions()
Get the assertions defined on this complex type- Returns:
- the set of asserts defined on this type, including those inherited from the base type
-
getAssertions
public java.util.Set<Assertion> getAssertions(Sweep sweep)
Get the assertions defined on this complex type that have a given streaming sweep- Parameters:
sweep
- the sweep of the assertions to be selected- Returns:
- the set of asserts defined on this type, including those inherited from the base type, where the sweep of the assertion is the requested sweep
-
lookForCycles
public void lookForCycles(java.util.Stack<SchemaComponent> references, SchemaCompiler compiler) throws SchemaException, MissingComponentException
This 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:
lookForCycles
in interfaceUserSchemaComponent
- Overrides:
lookForCycles
in 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 foundMissingComponentException
-
fixup
public boolean fixup(SchemaCompiler compiler) throws SchemaException
Check references from this component to other components- Specified by:
fixup
in interfaceUserSchemaComponent
- Overrides:
fixup
in classSchemaStructure
- 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 UserComplexType definition.- Specified by:
validate
in interfaceUserSchemaComponent
- Overrides:
validate
in classSchemaStructure
- Parameters:
compiler
- the schema compiler- Returns:
- true when this Schema definition is valid, otherwise false.
- Throws:
SchemaException
- if the ErrorListener decides that an error is fatal.
-
isValidRestriction
public boolean isValidRestriction(SchemaType base, SchemaCompiler compiler) throws SchemaException
Determine whether this type is a valid restriction of another type- Parameters:
base
- the specified base typecompiler
- used for error reporting- Returns:
- true if this type is a valid restriction of the specified base type
- Throws:
SchemaException
- if an error occurs
-
compile
public void compile(SchemaCompiler compiler) 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
protected void makeAutomaton(SchemaCompiler compiler) throws SchemaException
- Throws:
SchemaException
-
recompile
public void recompile(SchemaCompiler compiler) throws SchemaException
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
public FiniteStateMachine 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
public State 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.
-
makeExtendedParticle
public Particle makeExtendedParticle(SchemaCompiler compiler) throws SchemaException
Get the particle corresponding to this UserComplexType, combining it with the content model of the base type if this type is derived by extension. The resulting particle, as well as concatenating with the base content model if the type is derived by extension, will be simplified in that pointless particles will be removed and group references will be resolved (unless they have a significant minOccurs or maxOccurs).- Parameters:
compiler
- used for error reporting. May be null if the schema has already been fully validated.- Returns:
- The particle that combines the locally-defined content model with the content model of the type that this type is extending.
- Throws:
SchemaException
- if an error occurs
-
getParticle
public Particle getParticle()
Get the (extended) particle representing the content model of this complex type. This must be called only on a UserComplexType that has been validated.- Returns:
- the extended particle (the particle defined on this type, appended where necessary onto the particle of the type from which it is derived by extension)
-
isEmptiable
public boolean isEmptiable() throws MissingComponentException
Test whether the content model of this complexType allows empty content- Specified by:
isEmptiable
in interfaceComplexType
- Returns:
- true if empty content is valid
- Throws:
MissingComponentException
-
getElementParticleType
public SchemaType getElementParticleType(int elementName, 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.- Specified by:
getElementParticleType
in interfaceComplexType
- Parameters:
elementName
- Identifies the name of the child element within this content modelconsiderExtensions
- 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- Returns:
- the schema type associated with the child element particle with the given name. If there is no such particle, return null.
- Throws:
MissingComponentException
- if the schema is incomplete
-
getElementParticleCardinality
public int getElementParticleCardinality(int elementName, 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.- Specified by:
getElementParticleCardinality
in interfaceComplexType
- Parameters:
elementName
- Identifies the name of the child element within this content modelconsiderExtensions
- 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
- if the schema is incomplete
-
getAttributeUseType
public SimpleType getAttributeUseType(StructuredQName attributeName) 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.- Specified by:
getAttributeUseType
in interfaceComplexType
- Parameters:
attributeName
- Identifies the name of the required attribute use 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
-
getAttributeUseCardinality
public int getAttributeUseCardinality(StructuredQName attributeName) 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.
- Specified by:
getAttributeUseCardinality
in interfaceComplexType
- Parameters:
attributeName
- Identifies the name of the required attribute within this content model- 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
public boolean allowsAttributes() throws MissingComponentException
Ask whether 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 (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
public boolean containsElementWildcard() throws MissingComponentException
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
- Throws:
MissingComponentException
-
makeContextDeterminedTypeMapForElements
public void makeContextDeterminedTypeMapForElements() throws SchemaException
Build the context-determined type map for elements- Throws:
SchemaException
- if an error is encountered
-
getContextDeterminedTypeForElement
public SchemaType getContextDeterminedTypeForElement(StructuredQName fp)
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
public void makeContextDeterminedTypeMapForAttributes() throws SchemaException
Build the context-determined type map for attributes- Throws:
SchemaException
- if an error is encountered
-
getContextDeterminedTypeForAttribute
public SimpleType getContextDeterminedTypeForAttribute(StructuredQName fp)
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
-
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. The result includes elements defined in types that are defined by extension from this type.- Specified by:
gatherAllPermittedChildren
in interfaceComplexType
- Parameters:
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(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- 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
public SchemaType getDescendantElementType(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.- Specified by:
getDescendantElementType
in interfaceComplexType
- Parameters:
elementName
- 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(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.- Specified by:
getDescendantElementCardinality
in interfaceComplexType
- Parameters:
elementFingerprint
- the name of the required descendant element- Returns:
- the cardinality of the descendant element within this complex type
- Throws:
SchemaException
-
isSubsumedBy
public java.lang.String isSubsumedBy(ComplexType base, SchemaCompiler compiler) throws SchemaException
Test whether this complex type is subsumed by another complex type. The algorithm used is as published by Thompson and Tobin, XML Europe 2003.- Parameters:
base
- the other type (the type that this is derived from by restriction, validly or otherwise)compiler
- used for error reporting- Returns:
- null indicating that this type does indeed subsume the other; or a string indicating why it doesn't. If the string starts with "?", Saxon isn't able to prove subsumption one way or the other.
- Throws:
SchemaException
- if an error is encountered
-
elementParticleMatches
protected static java.lang.String elementParticleMatches(ElementDecl base, ElementDecl sub, SchemaCompiler compiler) throws MissingComponentException
Determine whether one element term matches another. This is a simplified version of the procedure in Edge.matches(), used only for xs:all content models- Parameters:
base
- the element declaration used in the base typesub
- the element declaration used in the derived typecompiler
- used for reporting warnings- Returns:
- null if the edges match, otherwise a string explaining why there is no match.
- Throws:
MissingComponentException
-
subsumesAll
public java.lang.String subsumesAll(UserComplexType sub, SchemaCompiler compiler) throws SchemaException
Test whether the particle of this complex type subsumes a complex type defined using xs:all- Parameters:
sub
- the derived typecompiler
- used for error reporting- Returns:
- null if this type validly subsumes the derived type; otherwise, a string that can be used as an error message to explain why the derivation is not valid
- Throws:
SchemaException
-
analyzeContentExpression
public void analyzeContentExpression(Expression expression, int kind) throws XPathException
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 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.DOCUMENT
- Throws:
XPathException
- if the expression will never deliver a value of the correct type (that is, of this type)
-
atomize
public AtomicSequence atomize(NodeInfo node) throws XPathException
Get the typed value of a node that is annotated with this schema type.- Specified by:
atomize
in interfaceSchemaType
- Parameters:
node
- the node whose typed value is required- Returns:
- the typed value. If requireSingleton is set to true, the result will always be an AtomicValue. In other cases it may be a Value representing a sequence whose items are atomic values.
- Throws:
XPathException
- if the node cannot be atomized, for example if this is a complex type with element-only content- Since:
- 8.5
-
checkTypeDerivation
public static void checkTypeDerivation(ComplexType derived, SchemaType base, int block) throws SchemaException
Check that a type is validly derived from a given type. This method is used only for complex types.- Parameters:
derived
- the derived typebase
- 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
-
elaborate
public void elaborate(SchemaCompiler compiler) throws SchemaException
Elaborate 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:
elaborate
in interfaceUserSchemaComponent
- Overrides:
elaborate
in classSchemaStructure
- Parameters:
compiler
- the schema compiler- Throws:
SchemaException
- if the schema is found to be invalid
-
serialize
public void serialize(SchemaModelSerializer serializer) throws XPathException
Serialize the schema component- Specified by:
serialize
in interfaceSerializableSchemaComponent
- Parameters:
serializer
- the object responsible for performing the serialization- Throws:
XPathException
- if serialization fails
-
getComponentAsFunction
public Function getComponentAsFunction()
Description copied from interface:SchemaComponent
Get the schema component in the form of a function item. This allows schema information to be made visible to XSLT or XQuery code. The function makes available the contents of the schema component as defined in the XSD specification. The function takes a string as argument representing a property name, and returns the corresponding property of the schema component. There is also a property "class" which returns the kind of schema component, for example "Attribute Declaration".- Specified by:
getComponentAsFunction
in interfaceSchemaComponent
- Overrides:
getComponentAsFunction
in classSchemaStructure
- Returns:
- the schema component represented as a function from property names to property values.
-
getComponentAsFunction
public static Function getComponentAsFunction(ComplexType type)
-
-