com.saxonica.schema
Class ElementParticle

java.lang.Object
  extended by com.saxonica.schema.SchemaStructure
      extended by com.saxonica.schema.SimpleComponentReference
          extended by com.saxonica.schema.Particle
              extended by com.saxonica.schema.ElementParticle
All Implemented Interfaces:
ComponentReference, UserSchemaComponent, Serializable, SourceLocator, SchemaComponent

public class ElementParticle
extends Particle
implements UserSchemaComponent

A reference to an element declaration within the content model of a complex type. This corresponds to an <xs:element ref="x"> element in the XML representation of a schema. Where a local element declaration appears in a content model, using the form <xs:element name="x">, both an element declaration and an element particle are created.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.saxonica.schema.Particle
UNBOUNDED
 
Fields inherited from interface net.sf.saxon.type.SchemaComponent
FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING
 
Constructor Summary
ElementParticle(SchemaAwareConfiguration config, SourceLocator locator)
          Creates a new element particle
 
Method Summary
 void compile(SchemaCompiler compiler)
          Compile this local element declaration, considered as a particle of some complex type, by compiling its own complex type definition.
 boolean fixup(SchemaCompiler compiler)
          Check references from this component to other components
 void gatherAllPermittedElements(IntHashSet result, boolean ignoreWildcards)
          Find the set of all element particles allowed within the content model of this particle, identified by their integer fingerprints.
 ElementDecl getDeclaration()
          Returns the ElementDecl that this element definition references.
 String getDisplayName()
          Returns the display name of this Element particle.
 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.
 String getName()
          Returns the local name of this Element particle.
 String getNamespaceURI()
          Get the namespace URI of this element particle
 Term getTerm()
          Get the term corresponding to this particle
 boolean isEmptiable()
          Determine if this particle can be empty
 boolean isPointless(ModelGroup container)
          Test whether the particle is pointless, as described in XML Schema Part 1 Schema Component Constraint: Particle Valid (Restriction)
 void serializeParticle(SchemaModelSerializer serializer)
          Serialize the particle
 void setReference(ElementDecl declaration)
          Set the reference to a specific (typically non-global) element declaration
 String toString()
           
 boolean validate(SchemaCompiler compiler)
          Check the validity (consistency) of this element definition.
 
Methods inherited from class com.saxonica.schema.Particle
computeParticleCardinality, getMaxOccurs, getMinOccurs, setMaxOccurs, setMinOccurs
 
Methods inherited from class com.saxonica.schema.SimpleComponentReference
getFingerprint, getNameCode, getSymbolSpace, getTarget, isResolved, setNameCode, setTarget, tryToResolve
 
Methods inherited from class com.saxonica.schema.SchemaStructure
elaborate, getColumnNumber, getConfiguration, getFixupStatus, getLineNumber, getPublicId, getSystemId, getValidationStatus, lookForCycles, setConfiguration, setFixupStatus, setLineNumber, setLocator, setSystemId, setValidationStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.saxonica.schema.UserSchemaComponent
elaborate, lookForCycles
 
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getValidationStatus
 
Methods inherited from interface com.saxonica.schema.ComponentReference
getConfiguration
 
Methods inherited from interface javax.xml.transform.SourceLocator
getColumnNumber, getLineNumber, getPublicId, getSystemId
 

Constructor Detail

ElementParticle

public ElementParticle(SchemaAwareConfiguration config,
                       SourceLocator locator)
Creates a new element particle

Parameters:
config - the Configuration to which this element declaration belongs
locator - identifies the location of the element declaration in the source schema document
Method Detail

getDisplayName

public String getDisplayName()
Returns the display name of this Element particle. This will be in the form of a lexical QName typically using the original prefix

Returns:
the local name of this element declaration

getNamespaceURI

public String getNamespaceURI()
Get the namespace URI of this element particle


getName

public String getName()
Returns the local name of this Element particle. The name returned, if not null, will be an NCName.

Returns:
the name of this element declaration

getDeclaration

public ElementDecl getDeclaration()
                           throws UnresolvedReferenceException
Returns the ElementDecl that this element definition references.

Returns:
the ElementDecl that this element definition references.
Throws:
UnresolvedReferenceException

setReference

public void setReference(ElementDecl declaration)
Set the reference to a specific (typically non-global) element declaration


isEmptiable

public boolean isEmptiable()
Determine if this particle can be empty

Specified by:
isEmptiable in class Particle
Returns:
true if this element, considered as a particle in a content model, can be matched by empty content (which is true if the minOccurs value is zero). The result is undefined for a global element declaration.

isPointless

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

Specified by:
isPointless in class Particle

fixup

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

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

validate

public boolean validate(SchemaCompiler compiler)
                 throws SchemaException
Check the validity (consistency) of this element definition.

Specified by:
validate in interface UserSchemaComponent
Specified by:
validate in class Particle
Parameters:
compiler -
Returns:
true if validation succeeded, false if errors were found.
Throws:
SchemaException - if an error is found and the error listener decides that the error is fatal

compile

public void compile(SchemaCompiler compiler)
             throws SchemaException
Compile this local element declaration, considered as a particle of some complex type, by compiling its own complex type definition.

Specified by:
compile in class Particle
Parameters:
compiler -
Throws:
SchemaException - if compilation fails.

getTerm

public Term getTerm()
Get the term corresponding to this particle

Specified by:
getTerm in class Particle
Returns:
the corresponding term

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

getElementParticleCardinality

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

gatherAllPermittedElements

public void gatherAllPermittedElements(IntHashSet result,
                                       boolean ignoreWildcards)
                                throws SchemaException
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 class Particle
Parameters:
result - an initially-empty integer set in which the results are accumulated
ignoreWildcards -
Throws:
SchemaException

toString

public String toString()
Overrides:
toString in class Object

serializeParticle

public void serializeParticle(SchemaModelSerializer serializer)
                       throws XPathException
Serialize the particle

Specified by:
serializeParticle in class Particle
Throws:
XPathException


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