com.saxonica.schema
Class Compositor

java.lang.Object
  extended bycom.saxonica.schema.SchemaStructure
      extended bycom.saxonica.schema.AbstractParticle
          extended bycom.saxonica.schema.Compositor
All Implemented Interfaces:
Particle, SchemaComponent, java.io.Serializable, javax.xml.transform.SourceLocator, Term, UserSchemaComponent
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 group

See Also:
Serialized Form

Field Summary
protected  java.util.List contentModel
          The list of particles making up the content model of this ModelGroup.
 
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
 
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
protected  boolean checkElements(IntHashMap map, PreparedSchema schema)
          Check that the elements defined as particles in this compositor are consistent
 void compile(PreparedSchema schema, UserComplexType subjectType)
          Compile this Compositor by compiling each of the particles contained in its content model.
 boolean containsAll()
          Test whether this compositor contains an xs:all compositor
 boolean fixup(PreparedSchema schema)
          Check references from this component to other components
 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.
 Term getTerm()
          Get the term corresponding to this particle
 boolean isEmpty()
          Return true if the content model is empty
 java.util.Iterator iterateParticles()
          Iterate over the Particles of the content model defined by this Compositor.
 void lookForCycles(PreparedSchema schema, java.util.Stack references)
          This method is called to look for cycles.
 void rewrite()
          Rewrite a particle prior to compiling it
 boolean validate(PreparedSchema schema)
          Checks the validity of this Compositor definition.
 
Methods inherited from class com.saxonica.schema.AbstractParticle
getMaxOccurs, getMinOccurs, setMaxOccurs, setMinOccurs
 
Methods inherited from class com.saxonica.schema.SchemaStructure
getColumnNumber, getFixupStatus, getLineNumber, getPublicId, getSchema, getSystemId, getValidationStatus, setFixupStatus, setLineNumber, setLocator, setSchema, setSystemId, setValidationStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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.Particle
isEmptiable
 

Field Detail

contentModel

protected java.util.List contentModel
The list of particles making up the content model of this ModelGroup. In this list, group references are not expanded: that is, the particles can be real particles, or group references.

Constructor Detail

Compositor

public Compositor()
Creates a new Compositor, with no name

Method Detail

addParticle

public void addParticle(Particle particle)
                 throws SchemaException
Adds a given Particle to the content model defined by this Compositor

Parameters:
particle - the Particle to be added
Throws:
SchemaException - if this particle cannot be added, for example when a group with the same name as the specified group already exists in the current scope

iterateParticles

public java.util.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.

isEmpty

public boolean isEmpty()
Return true if the content model is empty


containsAll

public boolean containsAll()
                    throws UnresolvedReferenceException
Test whether this compositor contains an xs:all compositor

Throws:
UnresolvedReferenceException

lookForCycles

public void lookForCycles(PreparedSchema schema,
                          java.util.Stack references)
                   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:
schema -
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.
Throws:
SchemaException
UnresolvedReferenceException

validate

public boolean validate(PreparedSchema schema)
                 throws SchemaException,
                        ValidationException
Checks the validity of this Compositor definition.

Specified by:
validate in interface UserSchemaComponent
Parameters:
schema - if this is not null, any errors that are detected should be reported using the error() method of this schema.
Returns:
true when this Schema definition is valid, otherwise false.
Throws:
SchemaException - when the error listener decides an error is fatal
ValidationException

checkElements

protected boolean checkElements(IntHashMap map,
                                PreparedSchema schema)
                         throws SchemaException,
                                UnresolvedReferenceException
Check that the elements defined as particles in this compositor are consistent

Parameters:
map - a HashMap that maps integers to ElementDecl's
Throws:
SchemaException
UnresolvedReferenceException

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

rewrite

public void rewrite()
Rewrite a particle prior to compiling it

Specified by:
rewrite in interface Particle
Overrides:
rewrite in class AbstractParticle

compile

public void compile(PreparedSchema schema,
                    UserComplexType subjectType)
             throws SchemaException,
                    ValidationException
Compile this Compositor by compiling each of the particles contained in its content model.

Specified by:
compile in interface Particle
Parameters:
schema - The containing schema (used to generate error messages)
subjectType - The containing complex type (used so that this can be registered with any elements appearing as particles in the content model, so that the complex type can be recompiled if the substitution group membership of the element declaration subsequently changes)
Throws:
SchemaException - if compilation fails.
ValidationException

fixup

public boolean fixup(PreparedSchema schema)
              throws SchemaException,
                     UnresolvedReferenceException
Check references from this component to other components

Specified by:
fixup in interface UserSchemaComponent
Parameters:
schema - The schema 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