Package com.saxonica.ee.schema
Class ElementDecl
java.lang.Object
com.saxonica.ee.schema.SchemaStructure
com.saxonica.ee.schema.ElementDecl
- All Implemented Interfaces:
ComponentWithValueConstraint,SerializableSchemaComponent,Term,UserSchemaComponent,SourceLocator,Location,IElementDecl,SchemaComponent,Locator
public class ElementDecl
extends SchemaStructure
implements UserSchemaComponent, SerializableSchemaComponent, ComponentWithValueConstraint, IElementDecl, Term
The object represents an element declaration. It may be a global element
declaration, or a local element declaration.
-
Constructor Summary
ConstructorsConstructorDescriptionElementDecl(EnterpriseConfiguration config, boolean global, SourceLocator locator) Creates a new element declaration -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIdentityConstraint(IdentityConstraintReference constraint) Adds the given IdentityConstraint to this element definition.voidAdds the name of the head of a substitutionGroup for this element definition.voidaddTypeAlternative(TypeAlternative alternative) Add a type alternative to the type alternative table.booleanallowsDerivation(int derivation) Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property (that is, the {substitution group exclusions} in the component modelbooleanapparentlyEquals(Object other) Perform a quick check whether this element declaration appears to be equal to another.booleanfixup(SchemaCompiler compiler) Check references from this component to other componentsprotected voidfixupSubstitutionGroup(SchemaCompiler compiler) Fix up the reference(s) to the head(s) of the substitition group(s)intgetBlock()Returns the value of the 'block' attribute for this element.Get the schema component in the form of a function item.Get the name of the schema componentGet the containing complex type.Get the containing named model group.Returns the name of this Element declaration in a form suitable for error messages.intGet the fingerprint of the name of this element declaration in the namePoolReturns the 'fixed' value defined for this element declaration.Return the lexical form of the "fixed" value defined for this element declaration.Returns a list of the identity constraints defined within this element definition.getName()Returns the local name of this Element declaration.Get the namespace resolver used when the fixed or value constraints include lexical QNamesintGet the substitution group exclusions of this element, that is, the value of the applicablefinalorfinalDefaultattributes.Returns the head(s) of the substitutionGroup for this element declaration, or null if there are none.Get the namespace URI of this element declaration.getType()Returns the Schema Type (ComplexType or SimpleType) of this Element Declaration.Get the type alternatives defined for this element.intGet the namepool fingerprint of the name of the element's type.Get the value constraint (fixed or default value) that applies to this element declaration, if anyinthashCode()booleanhasSameTypeTable(ElementDecl other) Test whether this element declaration has "the same" type table as another element declarationbooleanAsk whether any type alternatives are defined for this elementbooleanReturns true if this element definition is abstract.booleanisGlobal()Determine whether this element declaration is global.booleanDetermine whether or not instances of this element definition permit xsi:nil to be set to "yes".booleanisSameDeclaration(ElementDecl other) Test whether this is the same declaration as another declaration.voidlookForCycles(Stack<SchemaComponent> references, SchemaCompiler compiler) This method is called to look for cycles.voidRegister a complex type that contains this element as a particle.voidserialize(SchemaModelSerializer serializer) Serialize the schema componentvoidsetAbstract(boolean isAbstract) Sets whether or not this element definition is abstract.voidsetBlock(int block) Sets the value of the 'block' attribute for this element For internal use only.voidSets the containing complex type definition.voidSets the containing model group.voidsetElementName(StructuredQName elementName) voidsetFinalProhibitions(int finalValue) Sets the value of the 'final' property, indicating which types of derivation are not allowed.voidsetGeneratedId(String id) Set the generated Id for this element declarationvoidsetNamespaceResolver(NamespaceResolver resolver) Set the namespace resolver to be usedvoidsetNillable(boolean nillable) Sets whether or not instances of this element definition may set xsi:nil='true'.voidSets the schema type for this element declaration.voidSet the value constraint (fixed or default value) that applies to this element declarationtoString()booleanvalidate(SchemaCompiler compiler) Check the validity (consistency) of this element definition.Methods inherited from class com.saxonica.ee.schema.SchemaStructure
accessorFunction, elaborate, getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.saxonica.ee.schema.ComponentWithValueConstraint
getDefaultValue, getDefaultValueConstraint, getDefaultValueLexicalForm, getFixedValueConstraint, getValueConstraintAsFunctionMethods inherited from interface net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatusMethods inherited from interface com.saxonica.ee.schema.UserSchemaComponent
elaborate
-
Constructor Details
-
ElementDecl
Creates a new element declaration- Parameters:
config- the Configuration to which this element declaration belongsglobal- true if the element declaration is top-levellocator- identifies the location of the element declaration in the
-
-
Method Details
-
setGeneratedId
Set the generated Id for this element declaration- Overrides:
setGeneratedIdin classSchemaStructure- Parameters:
id- the generated ID
-
setNamespaceResolver
Set the namespace resolver to be used- Parameters:
resolver- the namespace resolver
-
getNamespaceResolver
Description copied from interface:ComponentWithValueConstraintGet the namespace resolver used when the fixed or value constraints include lexical QNames- Specified by:
getNamespaceResolverin interfaceComponentWithValueConstraint- Returns:
- the namespace resolver for lexical QNames
-
addIdentityConstraint
Adds the given IdentityConstraint to this element definition. For internal use only.- Parameters:
constraint- the IdentityConstraint to add.
-
setContainingComplexType
Sets the containing complex type definition. For internal use only.- Parameters:
type- the complex type containing this local element declaration
-
setContainingModelGroup
Sets the containing model group. For internal use only.- Parameters:
type- the named model group containing this local element declaration
-
getBlock
public int getBlock()Returns the value of the 'block' attribute for this element. This corresponds to the value of the {disallowed substitutions} property in the schema component model.- Returns:
- the value of the block attribute, as a bit-significant integer
using constants such as
Derivation.DERIVE_BY_SUBSTITUTION, indicating which kinds of derivation from this element declaration are blocked.
-
getValueConstraint
Get the value constraint (fixed or default value) that applies to this element declaration, if any- Specified by:
getValueConstraintin interfaceComponentWithValueConstraint- Returns:
- the applicable value constraint if there is one, or null otherwise
-
getSubstitutionGroupExclusions
public int getSubstitutionGroupExclusions()Get the substitution group exclusions of this element, that is, the value of the applicablefinalorfinalDefaultattributes. Corresponds to the property {substitution group exclusions} in the schema component model.- Returns:
- the substitution group exclusions, represented as a bit-significant integer,
the relevant bits being
Derivation.DERIVATION_EXTENSIONandDerivation.DERIVATION_RESTRICTION
-
allowsDerivation
public boolean allowsDerivation(int derivation) Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property (that is, the {substitution group exclusions} in the component model- Parameters:
derivation- the kind of derivation, e.g.Derivation.DERIVATION_EXTENSION- Returns:
- true if this kind of derivation is allowed
-
getContainingComplexType
Get the containing complex type. This represents one aspect of the {scope} property defined in the schema component model. If the element is a local element declaration and is defined as part of a complex type (and not as part of a named model group), returns the complex type definition. Otherwise, returns null.- Returns:
- the containing complex type definition if there is one, otherwise null
-
getContainingModelGroup
Get the containing named model group. This represents one aspect of the {scope} property defined in the schema component model. If the element is a local element declaration and is defined as part of a named model group (not as part of a complex type), returns the model group definition. Otherwise, returns null.- Returns:
- the containing model group definition if there is one, otherwise null
-
getFixedValue
Returns the 'fixed' value defined for this element declaration.- Specified by:
getFixedValuein interfaceComponentWithValueConstraint- Returns:
- the fixed value for this element declaration, or null if no fixed value was specified.
-
getFixedValueLexicalForm
Return the lexical form of the "fixed" value defined for this element declaration. This is the form as written in the source schema, after whitespace normalization- Specified by:
getFixedValueLexicalFormin interfaceComponentWithValueConstraint- Returns:
- the lexical form of the "fixed" value, or null if there is no fixed value
-
getIdentityConstraints
Returns a list of the identity constraints defined within this element definition. This corresponds to the {identity-constraint definitions} property in the schema component model.- Returns:
- a list of of
IdentityConstraintReferenceobjects contained within this element declaration.
-
getDisplayName
Returns the name of this Element declaration in a form suitable for error messages. This will be the Clark name- Returns:
- the name of this element declaration in Clark format
-
getName
Returns the local name of this Element declaration. The name returned, if not null, will be an NCName. This corresponds to the {name} property defined in the schema component model.- Returns:
- the local name of this element declaration, if it is global, or null if it is anonymous
-
getTargetNamespace
Get the namespace URI of this element declaration. This corresponds to the {targetNamespace} property defined in the schema component model.- Returns:
- the target namespace if the element declaration is global and the target namespace is not "absent". Return "" for a local element declaration or for a global element in a no-namespace schema.
-
getTypeFingerprint
public int getTypeFingerprint()Get the namepool fingerprint of the name of the element's type.- Returns:
- the fingerprint of the type, or -1 if none is available.
-
getType
Returns the Schema Type (ComplexType or SimpleType) of this Element Declaration. This corresponds to the {typeDefinition} property in the schema component model.- Specified by:
getTypein interfaceIElementDecl- Returns:
- the Schema Type of this Element Declaration.
- Throws:
MissingComponentException- if the reference from the element declaration to its type cannot be resolved.
-
getSubstitutionGroupOwners
Returns the head(s) of the substitutionGroup for this element declaration, or null if there are none. This corresponds to the {substitution group affiliation} property in the schema component model.- Returns:
- the element declarations representing the heads of the substitution groups in which this element declaration is a member, or an empty set if none is defined. These are the immediate parents in the substitution group lattice.
- Throws:
MissingComponentException- if the element is a member of a substitution group but no declaration of the referenced element is (yet) available
-
registerComplexTypeUsingThisElement
Register a complex type that contains this element as a particle. If new elements are added to the substitution group headed by this element, these complex types will need to be recompiled to permit the new substititution group members. For internal use only.- Parameters:
type- A complex type that contains this element as a particle.
-
isAbstract
public boolean isAbstract()Returns true if this element definition is abstract. This corresponds to the {abstract} property in the schema component model.- Specified by:
isAbstractin interfaceIElementDecl- Returns:
- true if this element definition is abstract
-
isNillable
public boolean isNillable()Determine whether or not instances of this element definition permit xsi:nil to be set to "yes". This corresponds to the {nillable} property in the schema component model.- Specified by:
isNillablein interfaceIElementDecl- Returns:
- true if instances conforming to this element definition may be nilled, and false otherwise.
-
isGlobal
public boolean isGlobal()Determine whether this element declaration is global. This represents one aspect of the {scope} property defined in the schema data model.- Returns:
- true if the element declaration is global, false if it is local
-
setAbstract
public void setAbstract(boolean isAbstract) Sets whether or not this element definition is abstract. For internal use only.- Parameters:
isAbstract- a boolean: when true indicates that this element definition is abstract
-
setBlock
public void setBlock(int block) Sets the value of the 'block' attribute for this element For internal use only.- Parameters:
block- the value of the block attribute for this element definition, indicating the types of derivation that are not allowed, as a bit-significant integer, using constants such asDerivation.DERIVATION_EXTENSION
-
setFinalProhibitions
public void setFinalProhibitions(int finalValue) Sets the value of the 'final' property, indicating which types of derivation are not allowed. For internal use only.- Parameters:
finalValue- the bit-significant code representing the final property, made up of values such asDerivation.DERIVE_BY_SUBSTITUTION
-
setValueConstraint
Set the value constraint (fixed or default value) that applies to this element declaration- Specified by:
setValueConstraintin interfaceComponentWithValueConstraint- Parameters:
vc- the value constraint
-
setNillable
public void setNillable(boolean nillable) Sets whether or not instances of this element definition may set xsi:nil='true'. For internal use only.- Parameters:
nillable- the flag when true indicates that instances of this element definition may be nilled
-
setElementName
-
getComponentName
Description copied from interface:IElementDeclGet the name of the schema component- Specified by:
getComponentNamein interfaceIElementDecl- Returns:
- the component name as a structured QName
-
getFingerprint
public int getFingerprint()Get the fingerprint of the name of this element declaration in the namePool- Specified by:
getFingerprintin interfaceIElementDecl- Returns:
- the fingerprint of the element name
-
addSubstitutionGroupHead
Adds the name of the head of a substitutionGroup for this element definition. For internal use only.- Parameters:
qName- the name of the head of the substitutionGroup of this element definition.
-
setTypeReference
Sets the schema type for this element declaration. For internal use only.- Parameters:
type- the schema type for this element declaration.
-
addTypeAlternative
Add a type alternative to the type alternative table. Note that the order in which alternatives are added is significant.- Parameters:
alternative- the type alternative to be added
-
hasTypeAlternatives
public boolean hasTypeAlternatives()Ask whether any type alternatives are defined for this element- Specified by:
hasTypeAlternativesin interfaceIElementDecl- Returns:
- true if type alternatives have been defined
-
getTypeAlternatives
Get the type alternatives defined for this element. This should be called only after callling hasTypeAlternatives() to check that there are any.- Returns:
- an ordered list of the type alternatives defined for this element declaration.
-
lookForCycles
public void lookForCycles(Stack<SchemaComponent> references, SchemaCompiler compiler) 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.In this particular case the cycles we are looking for are cycles in substitution group membership.
- Specified by:
lookForCyclesin interfaceUserSchemaComponent- Overrides:
lookForCyclesin classSchemaStructure- 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- used for error reporting- Throws:
SchemaException- if cycles are found
-
fixup
Check references from this component to other components- Specified by:
fixupin interfaceUserSchemaComponent- Overrides:
fixupin classSchemaStructure- Parameters:
compiler- used for error reporting- Returns:
- true if all is well, false if errors found
- Throws:
SchemaException
-
validate
Check the validity (consistency) of this element definition.- Specified by:
validatein interfaceUserSchemaComponent- Overrides:
validatein classSchemaStructure- Parameters:
compiler- used for error reporting- 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
-
fixupSubstitutionGroup
Fix up the reference(s) to the head(s) of the substitition group(s)- Parameters:
compiler- used for error reporting- Throws:
SchemaException- if any error occurs, for example a name that is referenced but not declared
-
isSameDeclaration
Test whether this is the same declaration as another declaration. They are considered to be the same declaration if they are derived from the same definition in the original XML representation (which can happen when there are multiple includes of the same file)- Parameters:
other- the declaration with which to compare this one- Returns:
- true if the two declarations are the same
-
hasSameTypeTable
Test whether this element declaration has "the same" type table as another element declaration- Parameters:
other- the other element declaration- Returns:
- true if the type tables are the same, false if they are different
- Throws:
MissingComponentException
-
toString
-
serialize
Serialize the schema component- Specified by:
serializein interfaceSerializableSchemaComponent- Parameters:
serializer- the object responsible for performing the serialization- Throws:
XPathException- if serialization fails
-
getComponentAsFunction
Description copied from interface:SchemaComponentGet the schema component in the form of a function item. This allows schema information to be made visible to XSLT or XQuery code. The function makes available the contents of the schema component as defined in the XSD specification. The function takes a string as argument representing a property name, and returns the corresponding property of the schema component. There is also a property "class" which returns the kind of schema component, for example "Attribute Declaration".- Specified by:
getComponentAsFunctionin interfaceSchemaComponent- Overrides:
getComponentAsFunctionin classSchemaStructure- Returns:
- the schema component represented as a function from property names to property values.
-
apparentlyEquals
Perform a quick check whether this element declaration appears to be equal to another. This is probabilistic, we don't check everything- Parameters:
other- the other element declaration- Returns:
- true if they appear to be the same element declaration.
-
hashCode
public int hashCode()
-