Package com.saxonica.ee.schema
Class ElementParticle
- java.lang.Object
-
- com.saxonica.ee.schema.SchemaStructure
-
- com.saxonica.ee.schema.SimpleComponentReference
-
- com.saxonica.ee.schema.Particle
-
- com.saxonica.ee.schema.ElementParticle
-
- All Implemented Interfaces:
ComponentReference
,UserSchemaComponent
,javax.xml.transform.SourceLocator
,Location
,SchemaComponent
,org.xml.sax.Locator
public class ElementParticle extends Particle
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.
-
-
Field Summary
-
Fields inherited from class com.saxonica.ee.schema.SimpleComponentReference
symbolSpace, target
-
-
Constructor Summary
Constructors Constructor Description ElementParticle(EnterpriseConfiguration config, javax.xml.transform.SourceLocator locator)
Creates a new element particle
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
containsElementWildcard()
Ask whether the particle contains an element wildcardElementParticle
copy()
Copy an element particleboolean
fixup(SchemaCompiler compiler)
Check references from this component to other componentsvoid
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.java.lang.String
getDisplayName()
Returns the display name of this Element particle.int
getElementParticleCardinality(int elementName)
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 elementFingerprint)
Find an element particle within this complex type definition having a given element name (identified by elementName), and return the schema type associated with that element particle.java.lang.String
getName()
Returns the local name of this Element particle.NamespaceUri
getNamespaceURI()
Get the namespace URI of this element particleTerm
getTerm()
Get the term corresponding to this particleboolean
isEmptiable()
Determine if this particle can be emptyboolean
isPointless(ModelGroup container)
Test whether the particle is pointless, as described in XML Schema Part 1 Schema Component Constraint: Particle Valid (Restriction)void
lookForCycles(java.util.Stack<SchemaComponent> references, SchemaCompiler compiler)
This method is called to look for cycles.void
serializeParticle(SchemaModelSerializer serializer)
Serialize the particlevoid
setReference(ElementDecl declaration)
Set the reference to a specific (typically non-global) element declarationjava.lang.String
toString()
boolean
validate(SchemaCompiler compiler)
Check the validity (consistency) of this element definition.-
Methods inherited from class com.saxonica.ee.schema.Particle
computeParticleCardinality, getComponentAsFunction, getMaxOccurs, getMinOccurs, isVulnerable, markVulnerableSubParticles, setMaxOccurs, setMinOccurs, setVulnerable
-
Methods inherited from class com.saxonica.ee.schema.SimpleComponentReference
getSymbolSpace, getTarget, getTargetComponentName, getTargetFingerprint, isDangling, isResolved, setTarget, setTargetComponentName, tryToResolve
-
Methods inherited from class com.saxonica.ee.schema.SchemaStructure
elaborate, getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.saxonica.ee.schema.ComponentReference
getConfiguration
-
Methods inherited from interface net.sf.saxon.s9api.Location
getColumnNumber, getLineNumber, getPublicId, getSystemId, saveLocation
-
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatus
-
Methods inherited from interface com.saxonica.ee.schema.UserSchemaComponent
elaborate
-
-
-
-
Constructor Detail
-
ElementParticle
public ElementParticle(EnterpriseConfiguration config, javax.xml.transform.SourceLocator locator)
Creates a new element particle- Parameters:
config
- the Configuration to which this element declaration belongslocator
- identifies the location of the element declaration in the source schema document
-
-
Method Detail
-
copy
public ElementParticle copy()
Copy an element particle- Returns:
- a copy of this particle
-
getDisplayName
public java.lang.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 NamespaceUri getNamespaceURI()
Get the namespace URI of this element particle- Returns:
- the target namespace of the element. Returns "" for the no-namespace case.
-
getName
public java.lang.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 MissingComponentException
Returns the ElementDecl that this element definition references.- Returns:
- the ElementDecl that this element definition references.
- Throws:
MissingComponentException
- if the reference from the element particle to the corresponding element declaration has not been resolved
-
setReference
public void setReference(ElementDecl declaration)
Set the reference to a specific (typically non-global) element declaration- Parameters:
declaration
- the element declaration to which this particle refers.
-
isEmptiable
public boolean isEmptiable()
Determine if this particle can be empty- Specified by:
isEmptiable
in classParticle
- 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 classParticle
- Parameters:
container
- the model group containing this particle; null if there is no containing model group- Returns:
- true if the particle is pointless (for example, a sequence of one item)
-
lookForCycles
public void lookForCycles(java.util.Stack<SchemaComponent> references, SchemaCompiler compiler) throws SchemaException, MissingComponentException
Description copied from class:SchemaStructure
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. This is a dummy implementation that does nothing; it must be overridden for components that can participate in cycles.- Specified by:
lookForCycles
in interfaceUserSchemaComponent
- Overrides:
lookForCycles
in classSchemaStructure
- Parameters:
references
- A stack of objects that contain direct or indirect references to this object, and that must therefore not be referred to from this object.compiler
- the schema compiler- Throws:
SchemaException
- if cycles are foundMissingComponentException
-
fixup
public boolean fixup(SchemaCompiler compiler) throws SchemaException
Check references from this component to other components- Specified by:
fixup
in interfaceUserSchemaComponent
- Specified by:
fixup
in classParticle
- Parameters:
compiler
- is used for reporting errors- Returns:
- true if all is well, false if errors found
- Throws:
SchemaException
-
validate
public boolean validate(SchemaCompiler compiler) throws SchemaException
Check the validity (consistency) of this element definition.- Specified by:
validate
in interfaceUserSchemaComponent
- Specified by:
validate
in classParticle
- Parameters:
compiler
- the schema 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 classParticle
- Parameters:
compiler
- the schema compiler- Throws:
SchemaException
- if compilation fails.
-
getTerm
public Term getTerm() throws MissingComponentException
Get the term corresponding to this particle- Specified by:
getTerm
in classParticle
- Returns:
- the corresponding term. For an Element particle, the corresponding term is the element declaration.
- Throws:
MissingComponentException
-
getElementParticleType
public SchemaType getElementParticleType(int elementFingerprint)
Find an element particle within this complex type definition having a given element name (identified by elementName), and return the schema type associated with that element particle. If there is no such particle, return null. If the elementName 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 classParticle
- Parameters:
elementFingerprint
- Identifies the name of the child element within this content model- Returns:
- the type of the element identified by the given name fingerprint. The consistency rule "Element Declarations Consistent" ensures that if there are multiple matching declarations, they have consistent types
-
getElementParticleCardinality
public int getElementParticleCardinality(int elementName) 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 ofStaticProperty.EXACTLY_ONE
,StaticProperty.ALLOWS_ZERO_OR_ONE
,StaticProperty.ALLOWS_ZERO_OR_MORE
,StaticProperty.ALLOWS_ONE_OR_MORE
, If there is no such particle, returnStaticProperty.EMPTY
.- Specified by:
getElementParticleCardinality
in classParticle
- Parameters:
elementName
- Identifies the name of the child element within this content model- Returns:
- the computed cardinality of this child element within the complex type
- Throws:
MissingComponentException
-
containsElementWildcard
public boolean containsElementWildcard()
Ask whether the particle contains an element wildcard- Specified by:
containsElementWildcard
in classParticle
- Returns:
- true if the particle is an element wildcard, or contains one
-
gatherAllPermittedElements
public void gatherAllPermittedElements(IntHashSet result, boolean ignoreWildcards) throws MissingComponentException
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 classParticle
- Parameters:
result
- an initially-empty integer set in which the results are accumulatedignoreWildcards
- if true, wildcards are ignored. If false, the result will be a set containing the value XS_INVALID, meaning that it is not possible to enumerate- Throws:
MissingComponentException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
serializeParticle
public void serializeParticle(SchemaModelSerializer serializer) throws XPathException, MissingComponentException
Serialize the particle- Specified by:
serializeParticle
in classParticle
- Parameters:
serializer
- the object responsible for serialization- Throws:
XPathException
- if writing the serialized form to the destination failsMissingComponentException
- if the schema cannot be serialized because some components are missing.
-
-