## com.saxonica.schema
Class Compositor

    java.lang.Object
      com.saxonica.schema.SchemaStructure
          com.saxonica.schema.AbstractParticle
              com.saxonica.schema.Compositor

All Implemented Interfaces:
  Particle, SerializableSchemaComponent, Term, UserSchemaComponent, Serializable, SourceLocator, SchemaComponent

Direct Known Subclasses:
  AllCompositor, ChoiceCompositor, ModelGroupDefinition, SequenceCompositor

    public abstract class Compositor

extends AbstractParticle
implements UserSchemaComponent, Term

An XML Schema Compositor: choice, sequence, or all. Also used for a named model group

See Also:
  Serialized Form

Field Summary

Fields inherited from class com.saxonica.schema.AbstractParticle
`UNBOUNDED`

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
`Compositor()` Creates a new Compositor, with no name

Method Summary
`void` `addParticle(Particle particle)` Adds a given Particle to the content model defined by this Compositor
`void` `compile(SchemaCompiler compiler)` Compile this Compositor by compiling each of the particles contained in its content model.
`boolean` `containsAll(boolean simplified)` Test whether this compositor contains an xs:all compositor
`boolean` `fixup(SchemaCompiler compiler)` Check references from this component to other components
`void` `gatherAllPermittedElements(IntHashSet result)` Find the set of all element particles allowed within the content model of this particle, identified by their integer fingerprints.
`int` `getContentModelSize()` Get the number of particles in the (unsimplified) content model
`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.
`List` `getListOfParticles(boolean simplified)` Get the list of particles
`List` `getSimplifiedContentModel()` Remove pointless particles from this content model (recursively), and replace group references by the content of the identified group
`Term` `getTerm()` Get the term corresponding to this particle
`boolean` `isEmpty()` Return true if the content model is empty
`boolean` `isPointless(Particle container)` Test whether the particle is pointless, as described in XML Schema Part 1 Schema Component Constraint: Particle Valid (Restriction)
`Iterator` `iterateParticles()` Iterate over the Particles of the content model defined by this Compositor.
`void` `lookForCycles(Stack references, SchemaCompiler compiler)` This method is called to look for cycles.
`void` `setContentModel(List particles)` Set the entire content model
`boolean` `validate(SchemaCompiler compiler)` Checks the validity of this Compositor definition.

Methods inherited from class com.saxonica.schema.AbstractParticle
`computeParticleCardinality, getMaxOccurs, getMinOccurs, setMaxOccurs, setMinOccurs`

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.SchemaComponent
`getValidationStatus`

Methods inherited from interface com.saxonica.schema.SerializableSchemaComponent
`getComponentTypeCode, serialize`

Methods inherited from interface com.saxonica.schema.Particle
`isEmptiable`

Constructor Detail

### Compositor

    public Compositor()

  Creates a new Compositor, with no name

Method Detail

### addParticle

    public void addParticle(Particle particle)

  Adds a given Particle to the content model defined by this Compositor

  Parameters:
    `particle` - the Particle to be added

### setContentModel

    public void setContentModel(List particles)

  Set the entire content model

  Parameters:
    `particles` - a List whose members are Particle objects

### isPointless

    public boolean isPointless(Particle container)

  Test whether the particle is pointless, as described in XML Schema Part 1 Schema Component Constraint: Particle Valid (Restriction)

  Specified by:
    `isPointless` in interface `Particle`
  Overrides:
    `isPointless` in class `AbstractParticle`

### iterateParticles

    public Iterator iterateParticles()

  Iterate over the Particles of the content model defined by this Compositor.

  Returns:
    an iterator over the immediately contained particles in the content model defined by this Compositor. Note that the iteration may return group references as well as "true" particles.

### getListOfParticles

    public List getListOfParticles(boolean simplified)

  Get the list of particles

  Parameters:
    `simplified` - set to true if the simplified content model is required (that is, the model after removing pointless particles and expanding group references)

### getContentModelSize

    public int getContentModelSize()

  Get the number of particles in the (unsimplified) content model

### isEmpty

    public boolean isEmpty()

  Return true if the content model is empty

### containsAll

    public boolean containsAll(boolean simplified)
                        throws UnresolvedReferenceException

  Test whether this compositor contains an xs:all compositor

  Parameters:
    `simplified` - set to false if we want to look at the original unsimplified content model, to true if we want the model after removing pointless particles
  Throws:
    `UnresolvedReferenceException`

### getSimplifiedContentModel

    public List getSimplifiedContentModel()

  Remove pointless particles from this content model (recursively), and replace group references by the content of the identified group

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

### validate

    public boolean validate(SchemaCompiler compiler)
                     throws SchemaException,
                            ValidationException

  Checks the validity of this Compositor definition.

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

### getElementParticleType

    public 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. 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 interface `Particle`
  Parameters:
    `fingerprint` - Identifies the name of the child element within this content model

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

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

### gatherAllPermittedElements

    public void gatherAllPermittedElements(IntHashSet result)
                                    throws SchemaException,
                                           ValidationException

  Find the set of all element particles allowed within the content model of this particle, identified by their integer fingerprints. Ignore wildcards.

  Specified by:
    `gatherAllPermittedElements` in interface `Particle`
  Parameters:
    `result` - an initially-empty integer set in which the results are accumulated
  Throws:
    `SchemaException`
    `ValidationException`

### compile

    public void compile(SchemaCompiler compiler)
                 throws SchemaException,
                        ValidationException

  Compile this Compositor by compiling each of the particles contained in its content model.

  Specified by:
    `compile` in interface `Particle`
  Parameters:
    `compiler` -
  Throws:
    `SchemaException` - if compilation fails.
    `ValidationException`

### fixup

    public boolean fixup(SchemaCompiler compiler)
                  throws SchemaException,
                         UnresolvedReferenceException

  Check references from this component to other components

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

### getTerm

    public Term getTerm()

  Get the term corresponding to this particle

  Specified by:
    `getTerm` in interface `Particle`
  Specified by:
    `getTerm` in class `AbstractParticle`
  Returns:
    the corresponding term

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