## com.saxonica.schema
Class UserComplexType

    java.lang.Object
      com.saxonica.schema.SchemaStructure
          com.saxonica.schema.SchemaTypeImpl
              com.saxonica.schema.UserComplexType

All Implemented Interfaces:
  SerializableSchemaComponent, UserSchemaComponent, Serializable, SourceLocator, ComplexType, SchemaComponent, SchemaType

    public class UserComplexType

extends SchemaTypeImpl
implements ComplexType, UserSchemaComponent

A user-defined complex type (that is, any complex type other than xs:anyType)

See Also:
  Serialized Form

Field Summary

Fields inherited from interface net.sf.saxon.type.SchemaType
`DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION, DERIVE_BY_SUBSTITUTION`

Fields inherited from interface net.sf.saxon.type.SchemaComponent
`FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING`

Fields inherited from interface com.saxonica.schema.SerializableSchemaComponent
`ALL_COMPOSITOR, ATOMIC_TYPE, ATTRIBUTE_DECL, ATTRIBUTE_GROUP, ATTRIBUTE_GROUP_REF, ATTRIBUTE_USE, ATTRIBUTE_WILDCARD, CHOICE_COMPOSITOR, COMPLEX_TYPE, ELEMENT_DECL, ELEMENT_PARTICLE, ELEMENT_WILDCARD, FACET, KEY, KEYREF, LIST_TYPE, MODEL_GROUP, MODEL_GROUP_REF, NOTATION, SEQUENCE_COMPOSITOR, UNION_TYPE, UNIQUE`

Constructor Summary
`UserComplexType(PreparedSchema schema, SourceLocator locator)` Creates a new Complextype with the given name

Method Summary
`void` `addAttributeGroupReference(AttributeGroupReference attrGroupRef)` Adds the given AttributeGroupReference to this UserComplexType
`void` `addAttributeUse(AttributeUse attrDecl)` Adds the given AttributeDecl to this UserComplexType.
`String` `allSubsumes(ComplexType sub, SchemaCompiler compiler)` Test whether an "all" particle subsumes another particle.
`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.
`Value` `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 redefined
`static 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 type
`boolean` `computeIsAllContent()` Compute whether this complex type has a content model defined by an xs:all compositor (after simplification to remove pointless particles)
`boolean` `fixup(SchemaCompiler compiler)` Check references from this component to other components
`AllCompositor` `getAllCompositor()` For a complex type with "all" content, get the "all" compositor.
`AttributeGroupDecl` `getAttributeGroup()` Returns the attribute group containing details of all the attributes defined for this complex type.
`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.
`int` `getBlock()` Returns the value of the 'block' attribute for this element
`AttributeGroupDecl` `getCombinedAttributeGroup()` Returns the attribute group containing details of all the attributes defined for this complex type.
`int` `getComponentTypeCode()` Get a unique number identifying the type of component
`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.
`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.
`Particle` `getExtendedParticle(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.
`AutomatonState` `getInitialState()` Get the initial state of the finite state machine used for validating against this 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 type
`SequenceIterator` `getTypedValue(NodeInfo node)` Get the typed value of a node that is annotated with this schema type
`boolean` `hasRegisteredExtension(UserComplexType extension)` Determine whether a particular complex type is among the registered extensions of this type
`boolean` `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 compositor
`boolean` `isAtomicType()` Test whether this SchemaType is an atomic type
`boolean` `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 content
`boolean` `isEmptyContent()` Test whether the contentType of this complexType is empty
`boolean` `isMixedContent()` Determine whether this complex type allows mixed content
`boolean` `isRestricted()` Returns true if this complexType is a restriction
`boolean` `isSimpleContent()` Returns true if this complexType has simple content; that is, if its {content type} is a simple type definition
`boolean` `isSimpleType()` Test whether this SchemaType is a simple type
`boolean` `isValidRestriction(SchemaType base, SchemaCompiler compiler)` Determine whether this type is a valid restriction of another type
`void` `lookForCycles(Stack references, SchemaCompiler compiler)` This method is called to look for cycles.
`void` `recompile(SchemaCompiler compiler)` Recompile the complex type when new members are added to the substitution group of an element
`void` `serialize(SchemaSerializer serializer)` Serialize the schema component
`void` `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` `setComplexContent(boolean complexContent)` Sets whether or not this complexType is a 'complexContent'
`void` `setMixed(boolean isMixed)` Sets whether this complex type allows mixed content
`void` `setParticle(Particle particle)` Sets the particle representing the content model of this complex type
`void` `setRestriction(boolean restricted)` Sets whether or not this complexType is a restriction
`void` `setSaxonDebug(boolean debug)` Set Saxon debugging on or off
`void` `setSimpleContent(boolean simpleContent)`
`void` `setSimpleContentTypeReference(TypeReference ref)`
`String` `subsumes(ComplexType sub, ISchemaCompiler icompiler)` Test whether this complex type subsumes another complex type.
`String` `subsumesAll(UserComplexType sub, SchemaCompiler compiler)` Test whether the particle of this complex type subsumes a complex type defined using xs:all
`boolean` `validate(SchemaCompiler compiler)` Checks the validity of this UserComplexType definition.

Methods inherited from class com.saxonica.schema.SchemaTypeImpl

`allowsDerivation, checkTypeDerivationIsOK, containingDeclarationIsElement, getBaseType, getBaseTypeFingerprint, getBaseTypeReference, getContainingDeclarationName, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getLocalName, getNameCode, getNamePool, isAnonymousType, isComplexType, isExternalType, isSameType, setBaseTypeReference, setContainingDeclaration, setDerivationMethod, setDerivationMethodName, setFinalProhibitions, setLocalName, setNameCode, setNamePool`

Methods inherited from class com.saxonica.schema.SchemaStructure
`getColumnNumber, getConfiguration, getFixupStatus, getLineNumber, getPublicId, getSystemId, getValidationStatus, setConfiguration, setFixupStatus, setLineNumber, setLocator, setSystemId, setValidationStatus`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface net.sf.saxon.type.SchemaType
`allowsDerivation, checkTypeDerivationIsOK, getBaseType, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getNameCode, isAnonymousType, isComplexType, isSameType`

Methods inherited from interface net.sf.saxon.type.SchemaComponent
`getValidationStatus`

Constructor Detail

### UserComplexType

    public UserComplexType(PreparedSchema schema,
                           SourceLocator locator)

  Creates a new Complextype with the given name

  Parameters:
    `schema` - the owning Schema

Method Detail

### setSaxonDebug

    public void setSaxonDebug(boolean debug)

  Set Saxon debugging on or off

### addAttributeUse

    public void addAttributeUse(AttributeUse attrDecl)

  Adds the given AttributeDecl to this UserComplexType. Doesn't throw an error if it's a duplicate: this is left to be checked at validation time

  Parameters:
    `attrDecl` - the AttributeDecl 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.

  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 (if derived by extension).

  Returns:
    an AttributeGroup holding the attribute details

### hasRegisteredExtension

    public boolean hasRegisteredExtension(UserComplexType extension)

  Determine whether a particular complex type is among the registered extensions of this type

### getBlock

    public int getBlock()

  Returns the value of the 'block' attribute for this element

  Specified by:
    `getBlock` in interface `SchemaType`
  Overrides:
    `getBlock` in class `SchemaTypeImpl`
  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 interface `ComplexType`
  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 interface `ComplexType`
  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

  Specified by:
    `isSimpleContent` in interface `ComplexType`
  Returns:
    true if this complexType has simple content

### setSimpleContent

    public void setSimpleContent(boolean simpleContent)

### 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 interface `ComplexType`

### computeIsAllContent

    public boolean computeIsAllContent()
                                throws ValidationException

  Compute whether this complex type has a content model defined by an xs:all compositor (after simplification to remove pointless particles)

  Throws:
    `ValidationException`

### getAllCompositor

    public AllCompositor getAllCompositor()
                                   throws ValidationException

  For a complex type with "all" content, get the "all" compositor. This method is always applied to the simplified content model (after removal of pointless particles)

  Throws:
    `ValidationException`

### setSimpleContentTypeReference

    public void setSimpleContentTypeReference(TypeReference ref)

### getSimpleContentTypeReference

    public TypeReference getSimpleContentTypeReference()

  Get the reference to the simple content type

### getSimpleContentType

    public SimpleType getSimpleContentType()

  For a complex type with simple content, return the simple type of the content. Otherwise, return null.

  Specified by:
    `getSimpleContentType` in interface `ComplexType`
  Returns:
    For a complex type with simple content, returns the simple type of the content. Otherwise, returns null.

### isRestricted

    public boolean isRestricted()

  Returns true if this complexType is a restriction

  Specified by:
    `isRestricted` in interface `ComplexType`
  Returns:
    true if this complexType is a restriction

### isEmptyContent

    public boolean isEmptyContent()

  Test whether the contentType of this complexType is empty

  Specified by:
    `isEmptyContent` in interface `ComplexType`
  Returns:
    true if the content model is defined as empty

### isSimpleType

    public boolean isSimpleType()

  Test whether this SchemaType is a simple type

  Specified by:
    `isSimpleType` in interface `SchemaType`
  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 interface `SchemaType`
  Returns:
    true if this SchemaType is an atomic type

### 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.

### 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.

### setComplexContent

    public void setComplexContent(boolean complexContent)

  Sets whether or not this complexType is a 'complexContent'

  Parameters:
    `complexContent` - true if this complexType is a 'complexContent'

### setMixed

    public void setMixed(boolean isMixed)

  Sets whether this complex type allows mixed content

  Parameters:
    `isMixed` - if true, this type allows mixed content

### isMixedContent

    public boolean isMixedContent()

  Determine whether this complex type allows mixed content

  Specified by:
    `isMixedContent` in interface `ComplexType`
  Returns:
    true, if and only if this type allows mixed content

### setRestriction

    public void setRestriction(boolean restricted)

  Sets whether or not this complexType is a restriction

  Parameters:
    `restricted` - true if this complexType is a restriction

### setParticle

    public void setParticle(Particle particle)
                     throws SchemaException

  Sets the particle representing the content model of this complex type

  Parameters:
    `particle` - the Particle to add
  Throws:
    `SchemaException` - if the particle cannot be added (for example, because there is another with the same name in the same scope)

### lookForCycles

    public void lookForCycles(Stack references,
                              SchemaCompiler compiler)
                       throws SchemaException,
                              UnresolvedReferenceException

  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 interface `UserSchemaComponent`
  Overrides:
    `lookForCycles` in class `SchemaStructure`
  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` -
  Throws:
    `SchemaException`
    `UnresolvedReferenceException`

### fixup

    public boolean fixup(SchemaCompiler compiler)
                  throws SchemaException

  Check references from this component to other components

  Specified by:
    `fixup` in interface `UserSchemaComponent`
  Parameters:
    `compiler` -
  Returns:
    true if all is well, false if errors found
  Throws:
    `SchemaException`

### validate

    public boolean validate(SchemaCompiler compiler)
                     throws SchemaException,
                            ValidationException

  Checks the validity of this UserComplexType definition.

  Specified by:
    `validate` in interface `UserSchemaComponent`
  Returns:
    true when this Schema definition is valid, otherwise false.
  Throws:
    `SchemaException` - if the ErrorListener decides that an error is fatal.
    `ValidationException`

### isValidRestriction

    public boolean isValidRestriction(SchemaType base,
                                      SchemaCompiler compiler)
                               throws SchemaException,
                                      ValidationException

  Determine whether this type is a valid restriction of another type

  Throws:
    `SchemaException`
    `ValidationException`

### compile

    public void compile(SchemaCompiler compiler)
                 throws SchemaException,
                        ValidationException

  Compile the finite-state machine for validating instances against this type

  Throws:
    `SchemaException`
    `ValidationException`

### recompile

    public void recompile(SchemaCompiler compiler)
                   throws SchemaException,
                          ValidationException

  Recompile the complex type when new members are added to the substitution group of an element

  Throws:
    `SchemaException`
    `ValidationException`

### cancelValidation

    public void cancelValidation()

  Cancel validation and compilation: this happens when the complex type is redefined

### getInitialState

    public AutomatonState getInitialState()

  Get the initial 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.

### getExtendedParticle

    public Particle getExtendedParticle(SchemaCompiler compiler)
                                 throws SchemaException,
                                        ValidationException

  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.
  Throws:
    `SchemaException`
    `ValidationException`

### isEmptiable

    public boolean isEmptiable()
                        throws SchemaException,
                               ValidationException

  Test whether the content model of this complexType allows empty content

  Specified by:
    `isEmptiable` in interface `ComplexType`
  Returns:
    true if empty content is valid
  Throws:
    `SchemaException`
    `ValidationException`

### getElementParticleType

    public SchemaType getElementParticleType(int fingerprint)
                                      throws SchemaException,
                                             ValidationException

  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.

  If the element particle is not defined within this type itself, try to find it within the types derived by extension from this type. If there is one extension that defines the particle, return the type of that particle. If there are several, then if the types are consistent, return that type, otherwise return AnyType. (We don't currently construct a union type).

  Specified by:
    `getElementParticleType` in interface `ComplexType`
  Parameters:
    `fingerprint` - Identifies the name of the child element within this content model
  Throws:
    `SchemaException`
    `ValidationException`

### getElementParticleCardinality

    public int getElementParticleCardinality(int fingerprint)
                                      throws SchemaException,
                                             ValidationException

  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 of `StaticProperty.EXACTLY_ONE`, `StaticProperty.ALLOWS_ZERO_OR_ONE`, `StaticProperty.ALLOWS_ZERO_OR_MORE`, `StaticProperty.ALLOWS_ONE_OR_MORE`, If there is no such particle, return `StaticProperty.EMPTY`.

  Specified by:
    `getElementParticleCardinality` in interface `ComplexType`
  Parameters:
    `fingerprint` - Identifies the name of the child element within this content model
  Throws:
    `SchemaException`
    `ValidationException`

### getAttributeUseType

    public SchemaType getAttributeUseType(int fingerprint)
                                   throws SchemaException,
                                          ValidationException

  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 interface `ComplexType`
  Parameters:
    `fingerprint` - Identifies the name of the child element within this content model
  Throws:
    `SchemaException`
    `ValidationException`

### subsumes

    public String subsumes(ComplexType sub,
                           ISchemaCompiler icompiler)
                    throws SchemaException,
                           ValidationException

  Test whether this complex type subsumes another complex type. The algorithm used is as published by Thompson and Tobin, XML Europe 2003.

  Specified by:
    `subsumes` in interface `ComplexType`
  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.
  Throws:
    `SchemaException`
    `ValidationException`

### allSubsumes

    public String allSubsumes(ComplexType sub,
                              SchemaCompiler compiler)
                       throws SchemaException,
                              ValidationException

  Test whether an "all" particle subsumes another particle. This test is always done after simplification of the content model

  Throws:
    `SchemaException`
    `ValidationException`

### subsumesAll

    public String subsumesAll(UserComplexType sub,
                              SchemaCompiler compiler)
                       throws SchemaException,
                              ValidationException

  Test whether the particle of this complex type subsumes a complex type defined using xs:all

  Throws:
    `SchemaException`
    `ValidationException`

### analyzeContentExpression

    public void analyzeContentExpression(Expression expression,
                                         int kind,
                                         StaticContext env)
                                  throws XPathException

  Analyze an expression to see whether the expression is capable of delivering a value of this type.

  Specified by:
    `analyzeContentExpression` in interface `SchemaType`
  Parameters:
    `expression` - the expression that delivers the content
    `kind` - the node kind whose content is being delivered: `Type.ELEMENT`, `Type.ATTRIBUTE`, or `Type.DOCUMENT`
    `env` -
  Throws:
    `XPathException` - if the expression will never deliver a value of the correct type

### getTypedValue

    public SequenceIterator getTypedValue(NodeInfo node)
                                   throws XPathException

  Get the typed value of a node that is annotated with this schema type

  Specified by:
    `getTypedValue` in interface `SchemaType`
  Parameters:
    `node` - the node whose typed value is required
  Returns:
    a SequenceIterator over the atomic values making up the typed value of the specified node. The objects returned by this iterator are of type `AtomicValue`
  Throws:
    `XPathException`

### atomize

    public Value atomize(NodeInfo node)
                  throws XPathException

  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 method `getTypedValue(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 interface `SchemaType`
  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`
  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 type
    `base` - the type from which this type is derived
    `block` - the derivations that are blocked by the relevant element declaration
  Throws:
    `SchemaException` - if the derivation is not allowed

### serialize

    public void serialize(SchemaSerializer serializer)
                   throws IOException

  Serialize the schema component

  Specified by:
    `serialize` in interface `SerializableSchemaComponent`
  Throws:
    `IOException`

### getComponentTypeCode

    public int getComponentTypeCode()

  Get a unique number identifying the type of component

  Specified by:
    `getComponentTypeCode` in interface `SerializableSchemaComponent`

Copyright (C) Michael H. Kay. All rights reserved.