Free Trial - Stylus Studio, The World's Best XML IDE!


com.saxonica.schema
Class Compositor

java.lang.Object
  |
  +--com.saxonica.schema.SchemaElement
        |
        +--com.saxonica.schema.AbstractParticle
              |
              +--com.saxonica.schema.Compositor
All Implemented Interfaces:
CircularityChecker, Particle, SchemaComponent, SchemaDeclaration, java.io.Serializable, javax.xml.transform.SourceLocator, Term, ValidationContext
Direct Known Subclasses:
AllCompositor, ChoiceCompositor, Group, SequenceCompositor

public abstract class Compositor
extends AbstractParticle
implements CircularityChecker, SchemaComponent, ValidationContext

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

See Also:
Serialized Form

Field Summary
protected  java.util.List contentModel
           
 
Fields inherited from class com.saxonica.schema.AbstractParticle
UNBOUNDED
 
Fields inherited from class com.saxonica.schema.SchemaElement
ANNOTATION, ANYTYPE, APPINFO, ATTRIBUTE, ATTRIBUTE_GROUP, COMPLEX_CONTENT, COMPLEX_TYPE, COMPOSITOR, DOCUMENTATION, ELEMENT, FACET, GROUP, IDENTITY_FIELD, IDENTITY_SELECTOR, KEY, KEYREF, LIST, REDEFINE, SCHEMA, SIMPLE_CONTENT, SIMPLE_TYPE, UNION, UNIQUE, UNKNOWN, WILDCARD_ATTRIBUTE, WILDCARD_ELEMENT
 
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(java.util.HashMap map, Schema schema)
          Check that the elements defined as particles in this compositor are consistent
 void compile(Schema 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(Schema schema)
          Check references from this component to other components
 java.lang.String getId()
          Returns the ID for this Compositor (that is, the value of the 'id' attribute if present)
 ElementDecl getLocalElementDeclaration(int fingerprint)
          Get the contained element declaration with a given name.
 short getStructureType()
          Returns the type of this Schema Structure
 boolean isEmpty()
          Return true if the content model is empty
 boolean isVoidValidationContext()
          Determine whether this is a void validation context (a context in which nothing will validate)
 java.util.Iterator iterateParticles()
          Returns an iterator over all the Particles of the content model defined by this Compositor.
 void lookForCycles(Schema schema, java.util.Stack references)
          This method is called to look for cycles.
 void setId(java.lang.String id)
          Sets the ID for this Compositor.
 boolean validate(Schema schema)
          Checks the validity of this Compositor definition.
 
Methods inherited from class com.saxonica.schema.AbstractParticle
getMaxOccurs, getMinOccurs, getTerm, setMaxOccurs, setMinOccurs
 
Methods inherited from class com.saxonica.schema.SchemaElement
getColumnNumber, getLineNumber, getPublicId, getSystemId, setLocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.saxonica.schema.Particle
isEmptiable
 

Field Detail

contentModel

protected java.util.List contentModel
Constructor Detail

Compositor

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

Method Detail

isVoidValidationContext

public boolean isVoidValidationContext()
Determine whether this is a void validation context (a context in which nothing will validate)

Specified by:
isVoidValidationContext in interface ValidationContext
Returns:
false: this validation context is not void

getId

public java.lang.String getId()
Returns the ID for this Compositor (that is, the value of the 'id' attribute if present)

Returns:
the ID for this Compositor, or null if no 'id' attribute is present

setId

public void setId(java.lang.String id)
Sets the ID for this Compositor. For internal use only.

Parameters:
id - the ID for this Compositor.

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()
Returns an iterator over all the Particles of the content model defined by this Compositor.

Returns:
an iterator over all the Particles of the content model defined by this Compositor.

isEmpty

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


getStructureType

public short getStructureType()
Returns the type of this Schema Structure

Specified by:
getStructureType in class SchemaElement
Returns:
the type of this Schema Structure

getLocalElementDeclaration

public ElementDecl getLocalElementDeclaration(int fingerprint)
Get the contained element declaration with a given name.

Parameters:
fingerprint - the fingerprint of the required element name
Returns:
the element declaration, or null if there is none with the required name

containsAll

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


lookForCycles

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

validate

public boolean validate(Schema schema)
                 throws javax.xml.transform.TransformerException
Checks the validity of this Compositor definition.

Specified by:
validate in interface SchemaComponent
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:
javax.xml.transform.TransformerException - when the error listener decides an error is fatal

checkElements

protected boolean checkElements(java.util.HashMap map,
                                Schema schema)
                         throws SchemaException
Check that the elements defined as particles in this compositor are consistent

SchemaException

compile

public void compile(Schema schema,
                    UserComplexType subjectType)
             throws SchemaException
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.

fixup

public boolean fixup(Schema schema)
              throws SchemaException
Description copied from interface: SchemaComponent
Check references from this component to other components

Specified by:
fixup in interface SchemaComponent
Parameters:
schema - The schema is used for reporting errors
Returns:
true if all is well, false if errors found
SchemaException


Stylus Studio features integrated development and debugging support for Saxon in the XQuery editor and XSLT editor.