public class UserComplexType extends UserDefinedType implements ComplexType, UserSchemaComponent, SerializableSchemaComponent
extendedTypes, finalProhibitions
OPEN_CONTENT_ABSENT, OPEN_CONTENT_INTERLEAVE, OPEN_CONTENT_NONE, OPEN_CONTENT_SUFFIX, VARIETY_ELEMENT_ONLY, VARIETY_EMPTY, VARIETY_MIXED, VARIETY_SIMPLE
DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION, DERIVE_BY_SUBSTITUTION
COMPONENT_FUNCTION_TYPE, FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING
Constructor and Description |
---|
UserComplexType(EnterpriseConfiguration config,
javax.xml.transform.SourceLocator locator)
Creates a new user-defined Complextype
|
Modifier and Type | Method and Description |
---|---|
void |
addAssertion(Assertion assertion)
Add an assertion to this complex type
|
void |
addAttributeGroupReference(AttributeGroupReference attrGroupRef)
Adds the given AttributeGroupReference to this UserComplexType
|
void |
addAttributeUse(AttributeUse use)
Adds the given AttributeUse to this UserComplexType.
|
void |
addNonInheritedAttributeUse(AttributeUse use)
Add an attribute use to the final (combined) content model for this complex type.
|
boolean |
allowsAttributes()
Ask whether this type (or any known type derived from it by extension) allows the element
to have one or more attributes.
|
void |
analyzeContentExpression(Expression expression,
int kind)
Analyze an expression to see whether the expression is capable of delivering a value of this
type.
|
AtomicSequence |
atomize(NodeInfo node)
Get the typed value of a node that is annotated with this schema type.
|
void |
cancelValidation()
Cancel validation and compilation: this happens when the complex type is redefined
|
static void |
checkTypeDerivation(ComplexType derived,
SchemaType base,
int block)
Check that a type is validly derived from a given type.
|
void |
compile(SchemaCompiler compiler)
Compile the finite-state machine for validating instances against this type
|
boolean |
computeIsAllContent()
Compute whether this complex type has a content model defined by an xs:all compositor
(after simplification to remove pointless particles)
|
boolean |
containsElementWildcard()
Ask whether this type (or any known type derived from it by extension) allows the element
to have children that match a wildcard
|
void |
elaborate(SchemaCompiler compiler)
Elaborate the schema component: after reloading a serialized schema component model,
this expands the component with derived information needed during validation episodes.
|
protected static java.lang.String |
elementParticleMatches(ElementDecl base,
ElementDecl sub,
SchemaCompiler compiler)
Determine whether one element term matches another.
|
boolean |
fixup(SchemaCompiler compiler)
Check references from this component to other components
|
void |
gatherAllPermittedChildren(java.util.HashSet<StructuredQName> children,
boolean ignoreWildcards)
Get a list of all the names of elements that can appear as children of an element having this
complex type, as integer fingerprints.
|
void |
gatherAllPermittedDescendants(java.util.HashSet<StructuredQName> descendants)
Get a list of all the names of elements that can appear as descendants of an element having this
complex type, as integer fingerprints.
|
ModelGroupParticle |
getAllCompositor()
For a complex type with "all" content, get the "all" model group.
|
java.util.Set<Assertion> |
getAssertions()
Get the assertions defined on this complex type
|
AttributeGroupDecl |
getAttributeGroup()
Returns the attribute group containing details of all the
attributes defined for this complex type.
|
int |
getAttributeUseCardinality(StructuredQName attributeName)
Find an attribute use within this complex type definition having a given attribute name
(identified by fingerprint), and return the cardinality associated with that attribute,
which will always be 0, 1, or 0-or-1.
|
SimpleType |
getAttributeUseType(StructuredQName attributeName)
Find an attribute use within this complex type definition having a given attribute name
(identified by fingerprint), and return the schema type associated with that attribute.
|
int |
getBlock()
Returns the value of the 'block' attribute for this element
|
AttributeGroupDecl |
getCombinedAttributeGroup()
Returns the attribute group containing details of all the
attributes defined for this complex type.
|
Function |
getComponentAsFunction()
Get the schema component in the form of a function item.
|
static Function |
getComponentAsFunction(ComplexType type) |
SimpleType |
getContextDeterminedTypeForAttribute(StructuredQName fp)
Get the context-determined type for a given attribute.
|
SchemaType |
getContextDeterminedTypeForElement(StructuredQName fp)
Get the context-determined type for a given child element.
|
int |
getDescendantElementCardinality(StructuredQName elementName)
Assuming an element is a permitted descendant in the content model of this type, determine
the cardinality of the element when it appears as a descendant.
|
SchemaType |
getDescendantElementType(StructuredQName elementName)
Assuming an element is a permitted descendant in the content model of this type, determine
the type of the element when it appears as a descendant.
|
int |
getElementParticleCardinality(StructuredQName elementName,
boolean considerExtensions)
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(StructuredQName elementName,
boolean considerExtensions)
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.
|
java.lang.String |
getEQName()
Get the name of this type as an EQName, that is, a string in the format Q{uri}local.
|
FiniteStateMachine |
getFiniteStateMachine()
Get the finite state machine used for validation against this type
|
State |
getInitialState()
Get the initial dynamic state of the finite state machine used for validating against
this type.
|
int |
getLanguageVersion()
Get the XML Schema language version
|
int |
getOpenContentMode()
Ask whether open content permitted on this complex type is interleaved or suffixed.
|
java.lang.String |
getOpenContentModeString() |
Wildcard |
getOpenContentWildcard()
Get the open content wildcard for this complex type.
|
Particle |
getParticle()
Get the (extended) particle representing the content model of this complex type.
|
SimpleType |
getSimpleContentType()
For a complex type with simple content, return the simple type of the content.
|
TypeReference |
getSimpleContentTypeReference()
Get the reference to the simple content type
|
int |
getVariety()
Get the variety of this complex type.
|
boolean |
hasAssertions()
Test whether there are any assertions defined on this complex type
|
boolean |
isAbstract()
Returns true if this UserComplexType has been marked as Abstract.
|
boolean |
isAllContent()
Test whether this complex type has "all" content, that is, a content model
using an xs:all compositor
|
boolean |
isAtomicType()
Ask whether this SchemaType is an atomic type
|
boolean |
isComplexContent()
Returns true if this complexType has complex content: that is, if its {content type}
is anything other than a simple type definition.
|
boolean |
isEmptiable()
Test whether the content model of this complexType allows empty content
|
boolean |
isEmptyContent()
Ask whether the contentType of this complexType is empty
|
boolean |
isIdRefType()
Ask whether this type is an IDREF or IDREFS type.
|
boolean |
isIdType()
Ask whether this type is an ID type.
|
boolean |
isMixedContent()
Ask whether this complex type allows mixed content
|
boolean |
isRestricted()
Ask whether this complexType is a restriction
|
boolean |
isSimpleContent()
Returns true if this complexType has simple content; that is, if its {content type}
is a simple type definition and its {variety} is simple.
|
boolean |
isSimpleType()
Ask whether this SchemaType is a simple type
|
java.lang.String |
isSubsumedBy(ComplexType base,
SchemaCompiler compiler)
Test whether this complex type is subsumed by another complex type.
|
boolean |
isValidRestriction(SchemaType base,
SchemaCompiler compiler)
Determine whether this type is a valid restriction of another type
|
void |
lookForCycles(java.util.Stack references,
SchemaCompiler compiler)
This method is called to look for cycles.
|
void |
makeContextDeterminedTypeMapForAttributes()
Build the context-determined type map for attributes
|
void |
makeContextDeterminedTypeMapForElements()
Build the context-determined type map for elements
|
Particle |
makeExtendedParticle(SchemaCompiler compiler)
Get the particle corresponding to this UserComplexType, combining it with the
content model of the base type if this type is derived by extension.
|
void |
recompile(SchemaCompiler compiler)
Recompile the complex type when new members are added to the substitution group of an element
|
void |
serialize(SchemaModelSerializer serializer)
Serialize the schema component
|
void |
setAbstract(boolean isAbstract)
Sets whether or not this UserComplexType should be abstract.
|
void |
setAnyAttribute(AttributeWildcard wildcard)
Sets the wildcard (anyAttribute) of the complexType.
|
void |
setBlock(int block)
Sets the value of the 'block' attribute for this UserComplexType.
|
void |
setEmptyCombinedAttributeGroup()
Set the combined attribute group to an empty set of attributes.
|
void |
setFiniteStateMachine(FiniteStateMachine machine)
Set the finite state machine.
|
void |
setNonInheritedAnyAttribute(AttributeWildcard wildcard)
Sets the wildcard (anyAttribute) of the complexType on both the locally-declared
and the combined attribute groups.
|
void |
setOpenContentWildcard(Wildcard wildcard,
java.lang.String mode,
boolean appliesToEmpty)
Set the open content details for this complex type
|
void |
setParticle(Particle particle)
Set the particle representing the content model of this complex type
|
void |
setRestriction(boolean restricted)
Set whether or not this complexType is a restriction
|
void |
setSaxonDebug(boolean debug)
Set Saxon debugging on or off
|
void |
setSimpleContentTypeReference(TypeReference ref)
For a complex type with simple content, set a reference to the simple type of the content
|
void |
setVariety(int variety)
Set the variety of this complex type
|
java.lang.String |
subsumesAll(UserComplexType sub,
SchemaCompiler compiler)
Test whether the particle of this complex type subsumes a complex type defined using xs:all
|
boolean |
validate(SchemaCompiler compiler)
Checks the validity of this UserComplexType definition.
|
allowsDerivation, checkTypeDerivationIsOK, containingDeclarationIsElement, getBaseType, getBaseTypeFingerprint, getBaseTypeReference, getContainingDeclarationName, getDerivationMethod, getDescription, getDisplayName, getExtensionTypes, getFinalProhibitions, getFingerprint, getName, getNamePool, getStructuredQName, getTargetNamespace, isAnonymousType, isComplexType, isExternalType, isSameType, isSameURI, registerExtensionType, setBaseTypeReference, setContainingDeclaration, setDerivationMethod, setDerivationMethodName, setExtendedTypes, setFinalProhibitions, setTypeName, toString
getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
allowsDerivation, checkTypeDerivationIsOK, getBaseType, getDerivationMethod, getDescription, getDisplayName, getFinalProhibitions, getFingerprint, getName, getStructuredQName, getSystemId, getTargetNamespace, isAnonymousType, isComplexType, isSameType
getRedefinitionLevel, getValidationStatus
public UserComplexType(EnterpriseConfiguration config, javax.xml.transform.SourceLocator locator)
config
- the Configuration to which this user-defined complex type belongslocator
- the location of this complex type within a schema documentpublic int getVariety()
ComplexType.VARIETY_EMPTY
, ComplexType.VARIETY_MIXED
, ComplexType.VARIETY_SIMPLE
, or
ComplexType.VARIETY_ELEMENT_ONLY
getVariety
in interface ComplexType
public java.lang.String getEQName()
getEQName
in interface SchemaType
getEQName
in class UserDefinedType
public void setSaxonDebug(boolean debug)
debug
- true to switch debugging on; false to switch it offpublic int getLanguageVersion()
Configuration.XSD10
or Configuration.XSD11
public void setFiniteStateMachine(FiniteStateMachine machine)
machine
- the FSM for this complex typepublic void addAttributeUse(AttributeUse use)
use
- the AttributeUse to add to this UserComplexTypepublic void setEmptyCombinedAttributeGroup()
public void addNonInheritedAttributeUse(AttributeUse use)
use
- the AttributeUse to add to this UserComplexTypepublic void addAttributeGroupReference(AttributeGroupReference attrGroupRef)
attrGroupRef
- the AttributeGroupReference to add to this
UserComplexTypepublic AttributeGroupDecl getAttributeGroup()
getCombinedAttributeGroup()
public AttributeGroupDecl getCombinedAttributeGroup()
public int getBlock()
getBlock
in interface SchemaType
getBlock
in class UserDefinedType
public boolean isAbstract()
isAbstract
in interface ComplexType
public boolean isComplexContent()
isComplexContent
in interface ComplexType
public boolean isSimpleContent()
isSimpleContent
in interface ComplexType
public boolean isAllContent()
isAllContent
in interface ComplexType
public boolean computeIsAllContent() throws SchemaException
SchemaException
- if an error is found in the schemapublic ModelGroupParticle getAllCompositor() throws MissingComponentException
MissingComponentException
public void setSimpleContentTypeReference(TypeReference ref)
ref
- a reference to a simple typepublic TypeReference getSimpleContentTypeReference()
public SimpleType getSimpleContentType() throws MissingComponentException
getSimpleContentType
in interface ComplexType
MissingComponentException
public boolean isRestricted()
isRestricted
in interface ComplexType
public boolean isEmptyContent()
isEmptyContent
in interface ComplexType
public boolean isMixedContent()
isMixedContent
in interface ComplexType
public boolean isSimpleType()
isSimpleType
in interface SchemaType
public boolean isAtomicType()
isAtomicType
in interface SchemaType
public boolean isIdType() throws MissingComponentException
isIdType
in interface SchemaType
MissingComponentException
public boolean isIdRefType() throws MissingComponentException
isIdRefType
in interface SchemaType
MissingComponentException
public Wildcard getOpenContentWildcard()
public int getOpenContentMode()
ComplexType.OPEN_CONTENT_NONE
, ComplexType.OPEN_CONTENT_ABSENT
,
ComplexType.OPEN_CONTENT_INTERLEAVE
, or ComplexType.OPEN_CONTENT_SUFFIX
public java.lang.String getOpenContentModeString()
public void setAbstract(boolean isAbstract)
isAbstract
- a boolean that when true makes this UserComplexType
abstract.public void setAnyAttribute(AttributeWildcard wildcard)
wildcard
- the attribute wildcardpublic void setNonInheritedAnyAttribute(AttributeWildcard wildcard)
wildcard
- the attribute wildcardpublic void setBlock(int block)
block
- the value of the block attribute for this
UserComplexType definition, as a bit-significant integer.public void setVariety(int variety)
variety
- the variety: one of of the values
ComplexType.VARIETY_EMPTY
, ComplexType.VARIETY_MIXED
, ComplexType.VARIETY_SIMPLE
, or
ComplexType.VARIETY_ELEMENT_ONLY
public void setRestriction(boolean restricted)
restricted
- true if this complexType is a restrictionpublic void setParticle(Particle particle) throws SchemaException
particle
- the Particle to addSchemaException
- if the particle cannot be added (for example,
because there is another with the same name in the same scope)public void setOpenContentWildcard(Wildcard wildcard, java.lang.String mode, boolean appliesToEmpty)
wildcard
- the open content wildcard, defined either by the mode
- the open content mode. This must be one of "interleave" or "suffix"appliesToEmpty
- set to true if this open content applies even when the type would otherwise have an empty
content modelpublic void addAssertion(Assertion assertion)
assertion
- the assertion to be addedpublic boolean hasAssertions()
hasAssertions
in interface ComplexType
public java.util.Set<Assertion> getAssertions()
public void lookForCycles(java.util.Stack references, SchemaCompiler compiler) throws SchemaException, MissingComponentException
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
MissingComponentException
public boolean fixup(SchemaCompiler compiler) throws SchemaException
fixup
in interface UserSchemaComponent
fixup
in class SchemaStructure
compiler
- used for error reportingSchemaException
public boolean validate(SchemaCompiler compiler) throws SchemaException
validate
in interface UserSchemaComponent
SchemaException
- if the ErrorListener decides that an error is fatal.public boolean isValidRestriction(SchemaType base, SchemaCompiler compiler) throws SchemaException
base
- the specified base typecompiler
- used for error reportingSchemaException
- if an error occurspublic void compile(SchemaCompiler compiler) throws SchemaException
compiler
- used for error reportingSchemaException
- to indicate an invalid schemapublic void recompile(SchemaCompiler compiler) throws SchemaException
compiler
- user for error reportingSchemaException
- if an error is encounteredpublic void cancelValidation()
public FiniteStateMachine getFiniteStateMachine()
public State getInitialState()
public Particle makeExtendedParticle(SchemaCompiler compiler) throws SchemaException
compiler
- used for error reporting. May be null if the schema has already been fully validated.SchemaException
- if an error occurspublic Particle getParticle()
public boolean isEmptiable() throws MissingComponentException
isEmptiable
in interface ComplexType
MissingComponentException
public SchemaType getElementParticleType(StructuredQName elementName, boolean considerExtensions) throws MissingComponentException
getElementParticleType
in interface ComplexType
elementName
- Identifies the name of the child element within this content modelconsiderExtensions
- if true, and if the element particle is not defined within this type itself,
try to find it within the types derived by extension from this type, and/or within the open content
model permitted by the type. If there is one extension that defines the particle, return
the type of that particle. If there are several, then if the types are consistent, return that type,MissingComponentException
public int getElementParticleCardinality(StructuredQName elementName, boolean considerExtensions) throws MissingComponentException
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 StaticProperty.EMPTY
. The method also searches
for wildcard particles, element particles in extension types, and wildcards defined as open content.getElementParticleCardinality
in interface ComplexType
elementName
- Identifies the name of the child element within this content modelconsiderExtensions
- if true, types derived by extension from this type should be taken into accountMissingComponentException
public SimpleType getAttributeUseType(StructuredQName attributeName) throws SchemaException
getAttributeUseType
in interface ComplexType
attributeName
- Identifies the name of the required attribute use within this content modelSchemaException
public int getAttributeUseCardinality(StructuredQName attributeName) throws SchemaException
getAttributeUseCardinality
in interface ComplexType
attributeName
- Identifies the name of the required attribute within this content modelSchemaException
public boolean allowsAttributes() throws MissingComponentException
allowsAttributes
in interface ComplexType
MissingComponentException
public boolean containsElementWildcard() throws MissingComponentException
containsElementWildcard
in interface ComplexType
MissingComponentException
public void makeContextDeterminedTypeMapForElements() throws SchemaException
SchemaException
- if an error is encounteredpublic SchemaType getContextDeterminedTypeForElement(StructuredQName fp)
fp
- the child element namepublic void makeContextDeterminedTypeMapForAttributes() throws SchemaException
SchemaException
- if an error is encounteredpublic SimpleType getContextDeterminedTypeForAttribute(StructuredQName fp)
fp
- the attribute namepublic void gatherAllPermittedChildren(java.util.HashSet<StructuredQName> children, boolean ignoreWildcards) throws SchemaException
gatherAllPermittedChildren
in interface ComplexType
children
- a set, initially empty, which on return will hold the names of all permitted
child elements; if the result contains the value XS_INVALID_NAME, this indicates that it is not possible to enumerate
all the children, typically because of wildcards. In this case the other contents of the set should
be ignoredignoreWildcards
- if set to true, wildcards are ignored; only the elements that match explicitSchemaException
public void gatherAllPermittedDescendants(java.util.HashSet<StructuredQName> descendants) throws SchemaException
gatherAllPermittedDescendants
in interface ComplexType
descendants
- an integer set, initially empty, which on return will hold the fingerprints of all permitted
descendant elements; if the result contains the value -1, this indicates that it is not possible to enumerate
all the descendants, typically because of wildcards. In this case the other contents of the set should
be ignored.SchemaException
public SchemaType getDescendantElementType(StructuredQName elementName) throws SchemaException
getDescendantElementType
in interface ComplexType
elementName
- the name of the required descendant elementSchemaException
public int getDescendantElementCardinality(StructuredQName elementName) throws SchemaException
getDescendantElementCardinality
in interface ComplexType
elementName
- the name of the required descendant elementSchemaException
public java.lang.String isSubsumedBy(ComplexType base, SchemaCompiler compiler) throws SchemaException
base
- the other type (the type that this is derived from by restriction, validly or otherwise)compiler
- used for error reportingSchemaException
- if an error is encounteredprotected static java.lang.String elementParticleMatches(ElementDecl base, ElementDecl sub, SchemaCompiler compiler) throws MissingComponentException
base
- the element declaration used in the base typesub
- the element declaration used in the derived typecompiler
- used for reporting warningsMissingComponentException
public java.lang.String subsumesAll(UserComplexType sub, SchemaCompiler compiler) throws SchemaException
sub
- the derived typecompiler
- used for error reportingSchemaException
public void analyzeContentExpression(Expression expression, int kind) throws XPathException
analyzeContentExpression
in interface SchemaType
expression
- the expression that delivers the content. If this is a Block, the sequence of
instructions within the block is checked by this method, and the individual instructions are
checked by a callback; in other cases the method calls expression.checkPermittedContents() which may pass
the analysis onto other expressions.kind
- the node kind whose content is being delivered: Type.ELEMENT
,
Type.ATTRIBUTE
, or Type.DOCUMENT
XPathException
- if the expression will never deliver a value of the correct type (that is, of this type)public AtomicSequence atomize(NodeInfo node) throws XPathException
atomize
in interface SchemaType
node
- the node whose typed value is requiredXPathException
- if the node cannot be atomized, for example if this is a complex type
with element-only contentpublic static void checkTypeDerivation(ComplexType derived, SchemaType base, int block) throws SchemaException
derived
- the derived typebase
- the type from which this type is derivedblock
- the derivations that are blocked by the relevant element declarationSchemaException
- if the derivation is not allowedpublic void elaborate(SchemaCompiler compiler) throws SchemaException
elaborate
in interface UserSchemaComponent
elaborate
in class SchemaStructure
compiler
- the schema compilerSchemaException
- if the schema is found to be invalidpublic 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 static Function getComponentAsFunction(ComplexType type)
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.