Class CompiledComplexType

java.lang.Object
com.saxonica.ee.schema.CompiledComplexType

public class CompiledComplexType extends Object
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 Details

  • Method Details

    • getConfiguration

      public EnterpriseConfiguration getConfiguration()
    • getType

      public UserComplexType getType()
    • getSchema

      public PreparedSchema 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 model
      schema -
      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 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. 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 model
      schema -
      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 ignored
      ignoreWildcards - 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 searched
      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(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 searched
      elementFingerprint - 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 model
      schema - 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 model
      schema -
      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.
      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
      Returns:
      true if the content model of this type, or its extensions, contains an element wildcard
      Throws:
      MissingComponentException
    • makeContextDeterminedTypeMapForElements

      public void makeContextDeterminedTypeMapForElements(PreparedSchema schema) 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(PreparedSchema schema) 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
    • 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, or Type.DOCUMENT
      schema -
      Throws:
      XPathException - if the expression will never deliver a value of the correct type (that is, of this type)
    • 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
    • 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

      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.