public class ElementDecl extends SchemaStructure implements UserSchemaComponent, SerializableSchemaComponent, ComponentWithValueConstraint, SchemaDeclaration, Term
SchemaComponent.ValidationStatus
COMPONENT_FUNCTION_TYPE
Constructor and Description |
---|
ElementDecl(EnterpriseConfiguration config,
boolean global,
javax.xml.transform.SourceLocator locator)
Creates a new element declaration
|
Modifier and Type | Method and Description |
---|---|
void |
addIdentityConstraint(IdentityConstraintReference constraint)
Adds the given IdentityConstraint to this element definition.
|
void |
addSubstitutionGroupHead(StructuredQName qName)
Adds the name of the head of a
substitutionGroup for this element definition.
|
void |
addSubstitutionGroupMember(ElementDecl member,
SchemaCompiler compiler)
Add a member of the substitution group that has this element as its head.
|
void |
addTypeAlternative(TypeAlternative alternative)
Add a type alternative to the type alternative table.
|
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
|
boolean |
equals(java.lang.Object other) |
boolean |
fixup(SchemaCompiler compiler)
Check references from this component to other components
|
protected void |
fixupSubstitutionGroup(SchemaCompiler compiler)
Fix up the reference(s) to the head(s) of the substitition group(s)
|
int |
getBlock()
Returns the value of the 'block' attribute for this element.
|
Function |
getComponentAsFunction()
Get the schema component in the form of a function item.
|
StructuredQName |
getComponentName()
Get the name of the schema component
|
UserComplexType |
getContainingComplexType()
Get the containing complex type.
|
ModelGroupDefinition |
getContainingModelGroup()
Get the containing named model group.
|
java.lang.String |
getDisplayName()
Returns the name of this Element declaration in a form suitable for error messages.
|
int |
getFingerprint()
Get the fingerprint of the name of this element declaration in the namePool
|
AtomicSequence |
getFixedValue()
Returns the 'fixed' value defined for this element declaration.
|
java.lang.Comparable |
getFixedValueComparisonKey()
Return the Comparable that can be used to compare the "fixed" value against other values using
XML Schema comparison semantics.
|
java.lang.String |
getFixedValueLexicalForm()
Return the lexical form of the "fixed" value defined for this element declaration.
|
java.util.List<IdentityConstraintReference> |
getIdentityConstraints()
Returns a list of the identity constraints defined within
this element definition.
|
java.lang.String |
getName()
Returns the local name of this Element declaration.
|
NamespaceResolver |
getNamespaceResolver()
Get the namespace resolver used when the fixed or value constraints include lexical QNames
|
int |
getSubstitutionGroupExclusions()
Get the substitution group exclusions of this element, that is, the value of
the applicable
final or finalDefault attributes. |
java.util.Collection<ElementDecl> |
getSubstitutionGroupMembers()
Get the known members of the substitution group of this element, as a Set
containing the ElementDecl objects.
|
java.util.Set<ElementDecl> |
getSubstitutionGroupOwners()
Returns the head(s) of the substitutionGroup for this element declaration, or
null if there are none.
|
java.lang.String |
getTargetNamespace()
Get the namespace URI of this element declaration.
|
SchemaType |
getType()
Returns the Schema Type (ComplexType or SimpleType) of this Element Declaration.
|
java.util.List<TypeAlternative> |
getTypeAlternatives()
Get the type alternatives defined for this element.
|
int |
getTypeFingerprint()
Get the namepool fingerprint of the name of the element's type.
|
ValueConstraint |
getValueConstraint()
Get the value constraint (fixed or default value) that applies to this element declaration,
if any
|
int |
hashCode() |
boolean |
hasSameTypeTable(ElementDecl other)
Test whether this element declaration has "the same" type table as another element
declaration
|
boolean |
hasTypeAlternatives()
Ask whether any type alternatives are defined for this element
|
boolean |
isAbstract()
Returns true if this element definition is abstract.
|
boolean |
isGlobal()
Determine whether this element declaration is global.
|
boolean |
isNillable()
Determine whether or not instances of this element definition
permit xsi:nil to be set to "yes".
|
boolean |
isSameDeclaration(ElementDecl other)
Test whether this is the same declaration as another declaration.
|
void |
lookForCycles(java.util.Stack references,
SchemaCompiler compiler)
This method is called to look for cycles.
|
NodeTest |
makeSchemaNodeTest()
Create a NodeTest that implements the semantics of schema-element(name) or
schema-attribute(name) applied to this element or attribute declaration.
|
void |
registerComplexTypeUsingThisElement(UserComplexType type)
Register a complex type that contains this element as a particle.
|
void |
serialize(SchemaModelSerializer serializer)
Serialize the schema component
|
void |
setAbstract(boolean isAbstract)
Sets whether or not this element definition is abstract.
|
void |
setBlock(int block)
Sets the value of the 'block' attribute for this element
For internal use only.
|
void |
setContainingComplexType(UserComplexType type)
Sets the containing complex type definition.
|
void |
setContainingModelGroup(ModelGroupDefinition type)
Sets the containing model group.
|
void |
setElementName(StructuredQName elementName) |
void |
setElementName(StructuredQName elementName,
int fingerprint)
Set the name of this element declaration
|
void |
setFinalProhibitions(int finalValue)
Sets the value of the 'final' property, indicating which
types of derivation are not allowed.
|
void |
setGeneratedId(java.lang.String id)
Set the generated Id for this element declaration
|
void |
setNamespaceResolver(NamespaceResolver resolver)
Set the namespace resolver to be used
|
void |
setNillable(boolean nillable)
Sets whether or not instances of this element definition may
set xsi:nil='true'.
|
void |
setTypeReference(TypeReference type)
Sets the schema type for this element declaration.
|
void |
setValueConstraint(ValueConstraint vc)
Set the value constraint (fixed or default value) that applies to this element
declaration
|
java.lang.String |
toString() |
boolean |
validate(SchemaCompiler compiler)
Check the validity (consistency) of this element definition.
|
elaborate, getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
elaborate
getRedefinitionLevel, getValidationStatus
getDefaultValue, getDefaultValueConstraint, getDefaultValueLexicalForm, getFixedValueConstraint, getValueConstraintAsFunction
public ElementDecl(EnterpriseConfiguration config, boolean global, javax.xml.transform.SourceLocator locator)
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 thepublic void setGeneratedId(java.lang.String id)
setGeneratedId
in class SchemaStructure
id
- the generated IDpublic void setNamespaceResolver(NamespaceResolver resolver)
resolver
- the namespace resolverpublic NamespaceResolver getNamespaceResolver()
ComponentWithValueConstraint
getNamespaceResolver
in interface ComponentWithValueConstraint
public void addIdentityConstraint(IdentityConstraintReference constraint)
constraint
- the IdentityConstraint to add.public void setContainingComplexType(UserComplexType type)
type
- the complex type containing this local element declarationpublic void setContainingModelGroup(ModelGroupDefinition type)
type
- the named model group containing this local element declarationpublic int getBlock()
SchemaType.DERIVE_BY_SUBSTITUTION
, indicating
which kinds of derivation from this element declaration are blocked.public ValueConstraint getValueConstraint()
getValueConstraint
in interface ComponentWithValueConstraint
public int getSubstitutionGroupExclusions()
final
or finalDefault
attributes.
Corresponds to the property {substitution group exclusions} in the schema component
model.SchemaType.DERIVATION_EXTENSION
and
SchemaType.DERIVATION_RESTRICTION
public boolean allowsDerivation(int derivation)
derivation
- the kind of derivation, e.g. SchemaType.DERIVATION_EXTENSION
public UserComplexType getContainingComplexType()
public ModelGroupDefinition getContainingModelGroup()
public AtomicSequence getFixedValue()
getFixedValue
in interface ComponentWithValueConstraint
public java.lang.String getFixedValueLexicalForm()
getFixedValueLexicalForm
in interface ComponentWithValueConstraint
public java.lang.Comparable getFixedValueComparisonKey()
public java.util.List<IdentityConstraintReference> getIdentityConstraints()
IdentityConstraintReference
objects contained within
this element declaration.public java.lang.String getDisplayName()
public java.lang.String getName()
public java.lang.String getTargetNamespace()
public int getTypeFingerprint()
public SchemaType getType() throws MissingComponentException
getType
in interface SchemaDeclaration
MissingComponentException
- if the reference from the element declaration
to its type cannot be resolved.public java.util.Set<ElementDecl> getSubstitutionGroupOwners() throws MissingComponentException
MissingComponentException
- if the element is a member of a substitution group but
no declaration of the referenced element is (yet) availablepublic java.util.Collection<ElementDecl> getSubstitutionGroupMembers()
public void addSubstitutionGroupMember(ElementDecl member, SchemaCompiler compiler) throws SchemaException
This method may be called at any time, for example when a new schema is loaded as a result of validating an instance document. The method is therefore synchronized, since the schema may be used in several threads concurrently. Adding a new member to a substitution group means that all complex type definitions that include this element in their content model must be recompiled.
It is not possible to add to a substitution group once the element declaration has been used, either for validating a source document or for compiling stylesheets or schemas.
member
- The element declaration to be added to the substitution group of which this
element declaration is the head. Elements are added to each ancestor in the substitution
group hierarchy.compiler
- used for error reportingSchemaException
- if a fatal error occurspublic void registerComplexTypeUsingThisElement(UserComplexType type)
type
- A complex type that contains this element as a particle.public boolean isAbstract()
isAbstract
in interface SchemaDeclaration
public boolean isNillable()
isNillable
in interface SchemaDeclaration
public boolean isGlobal()
public void setAbstract(boolean isAbstract)
isAbstract
- a boolean: when true indicates that this
element definition is abstractpublic void setBlock(int block)
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 as SchemaType.DERIVATION_EXTENSION
public void setFinalProhibitions(int finalValue)
finalValue
- the bit-significant code representing the final property,
made up of values such as SchemaType.DERIVE_BY_SUBSTITUTION
public void setValueConstraint(ValueConstraint vc)
setValueConstraint
in interface ComponentWithValueConstraint
vc
- the value constraintpublic void setNillable(boolean nillable)
nillable
- the flag when true indicates that instances
of this element definition may be nilledpublic void setElementName(StructuredQName elementName, int fingerprint)
elementName
- the element namepublic void setElementName(StructuredQName elementName)
public StructuredQName getComponentName()
SchemaDeclaration
getComponentName
in interface SchemaDeclaration
public int getFingerprint()
getFingerprint
in interface SchemaDeclaration
public void addSubstitutionGroupHead(StructuredQName qName)
qName
- the name of the head of the
substitutionGroup of this element definition.public void setTypeReference(TypeReference type)
type
- the schema type for this element declaration.public void addTypeAlternative(TypeAlternative alternative)
alternative
- the type alternative to be addedpublic boolean hasTypeAlternatives()
hasTypeAlternatives
in interface SchemaDeclaration
public java.util.List<TypeAlternative> getTypeAlternatives()
public void lookForCycles(java.util.Stack references, SchemaCompiler compiler) throws SchemaException
In this particular case the cycles we are looking for are cycles in substitution group membership.
lookForCycles
in interface UserSchemaComponent
lookForCycles
in class SchemaStructure
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 reportingSchemaException
- if cycles are foundpublic boolean fixup(SchemaCompiler compiler) throws SchemaException
fixup
in interface UserSchemaComponent
fixup
in class SchemaStructure
compiler
- used for error reportingSchemaException
public NodeTest makeSchemaNodeTest() throws MissingComponentException
makeSchemaNodeTest
in interface SchemaDeclaration
MissingComponentException
- if the type of the declaration is not present in the schema.public boolean validate(SchemaCompiler compiler) throws SchemaException
validate
in interface UserSchemaComponent
compiler
- used for error reportingSchemaException
- if an error is found and the
error listener decides that the error is fatalprotected void fixupSubstitutionGroup(SchemaCompiler compiler) throws SchemaException
compiler
- used for error reportingSchemaException
- if any error occurs, for example a name that is referenced
but not declaredpublic boolean isSameDeclaration(ElementDecl other)
other
- the declaration with which to compare this onepublic boolean hasSameTypeTable(ElementDecl other) throws MissingComponentException
other
- the other element declarationMissingComponentException
public java.lang.String toString()
toString
in class java.lang.Object
public void serialize(SchemaModelSerializer serializer) throws XPathException
serialize
in interface SerializableSchemaComponent
serializer
- the object responsible for performing the serializationMissingComponentException
- if the component cannot be serialized because it contains dangling referencesXPathException
- if serialization failspublic Function getComponentAsFunction()
SchemaComponent
getComponentAsFunction
in interface SchemaComponent
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.