public final class AttributeUse extends SimpleComponentReference implements UserSchemaComponent
This corresponds to an xs:attribute ref="" element in the XML representation of the schema.
Technically, a local attribute declaration (a non global xs:attribute name="") should be represented by two schema components, an attribute use and an attribute declaration. We don't currently do this, instead the containing attribute group refers to the attribute declaration directly.
Modifier and Type | Field and Description |
---|---|
static short |
OPTIONAL
Value representing use="optional"
|
static short |
PROHIBITED
Value representing use="prohibited"
|
static short |
REQUIRED
Value representing use="required"
|
symbolSpace, target
COMPONENT_FUNCTION_TYPE, FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING
Constructor and Description |
---|
AttributeUse(EnterpriseConfiguration config)
Creates a new Attribute Use in the given schema.
|
Modifier and Type | Method and Description |
---|---|
boolean |
fixup(SchemaCompiler compiler)
Fix up references to other elements in the schema.
|
AttributeDecl |
getAttributeDeclaration()
Get the corresponding attribute declaration
|
int |
getCardinality()
Get the value of the "use" attribute, expressed as a Cardinality value
of
StaticProperty.EXACTLY_ONE , StaticProperty.EMPTY , or
StaticProperty.ALLOWS_ZERO_OR_ONE |
Function |
getComponentAsFunction()
Get the schema component in the form of a function item.
|
AttributeGroupDecl |
getContainingAttributeGroupDecl()
Get the attribute group declaration containing this attribute use, if any
|
java.lang.String |
getDefaultValue()
Returns the default value of this attribute use.
|
java.lang.String |
getDisplayName()
Returns the name of the attribute defined by this AttributeDecl.
|
AtomicSequence |
getFixedValue()
Returns the fixed value of this attribute use.
|
java.lang.String |
getFixedValueLexicalForm()
Returns the lexical form of the fixed value of this attribute use.
|
java.lang.String |
getUnderlyingDefaultValue()
Get the default value of this attribute use if there is one; if there is none, get
the default value of the corresponding attribute declaration; if the declaration
defines no default value, return null
|
AtomicSequence |
getUnderlyingFixedValue()
Returns the fixed value of this attribute use, or of the corresponding attribute
declaration if the attribute use has no fixed value.
|
java.lang.String |
getUse()
Get the value of the 'use' attribute for this attribute
declaration or attribute reference.
|
boolean |
isInheritable()
Ask whether this attribute is inheritable
|
boolean |
isOptional()
Returns true if the use attribute is equal to "optional".
|
boolean |
isProhibited()
Returns true if the use attribute is equal to "prohibited".
|
boolean |
isRequired()
Returns true if the 'use' attribute is equal to REQUIRED and
there is no specified value.
|
void |
serialize(SchemaModelSerializer serializer)
Serialize the schema component
|
void |
setContainingAttributeGroupDecl(AttributeGroupDecl containingAttributeGroupDecl)
Set the attribute group declaration containing this attribute use, if any
|
void |
setDefaultValue(java.lang.String value)
Sets the default value.
|
void |
setFixedValue(AtomicSequence value)
Sets the fixed value.
|
void |
setFixedValueLexicalForm(java.lang.String value)
Sets the lexical form of the fixed value.
|
void |
setInheritable(int inherit)
Say whether this attribute is inheritable
|
void |
setNamespaceResolver(NamespaceResolver resolver)
Set the namespace resolver for resolving QName-valued fixed and default values
|
void |
setUse(short value)
Sets the 'use' attribute of this attribute declaration.
|
boolean |
testFixedValue(java.lang.CharSequence value,
NamespaceResolver resolver)
Test a value against the fixed value.
|
void |
tryToResolve(SchemaCompiler compiler)
Attempt to resolve this reference using the components defined in a given schema.
|
boolean |
validate(SchemaCompiler compiler)
Checks the validity of this Attribute Use
|
getSymbolSpace, getTarget, getTargetComponentName, isDangling, isResolved, setTarget, setTargetComponentName
elaborate, getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, lookForCycles, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
elaborate, lookForCycles
getRedefinitionLevel, getValidationStatus
getConfiguration
getColumnNumber, getLineNumber, getPublicId, getSystemId, saveLocation
public static final short OPTIONAL
public static final short PROHIBITED
public static final short REQUIRED
public AttributeUse(EnterpriseConfiguration config)
config
- the Configuration that contains the new attributeUsepublic void tryToResolve(SchemaCompiler compiler)
SimpleComponentReference
tryToResolve
in interface ComponentReference
tryToResolve
in class SimpleComponentReference
compiler
- The compiler being used to compile the referring component.
This is assumed to know about the schema containing the candidate target components for the reference. If
null, the schema containing the reference is used.public AttributeDecl getAttributeDeclaration() throws MissingComponentException
MissingComponentException
- if the reference from the AttributeUse
to the AttributeDecl has not been resolvedpublic AttributeGroupDecl getContainingAttributeGroupDecl()
public void setContainingAttributeGroupDecl(AttributeGroupDecl containingAttributeGroupDecl)
containingAttributeGroupDecl
- the containing attribute declaration, or nullpublic java.lang.String getDisplayName()
public java.lang.String getUse()
public int getCardinality() throws MissingComponentException
StaticProperty.EXACTLY_ONE
, StaticProperty.EMPTY
, or
StaticProperty.ALLOWS_ZERO_OR_ONE
MissingComponentException
public java.lang.String getDefaultValue()
public java.lang.String getUnderlyingDefaultValue() throws MissingComponentException
MissingComponentException
public AtomicSequence getFixedValue()
public java.lang.String getFixedValueLexicalForm()
public AtomicSequence getUnderlyingFixedValue() throws MissingComponentException
MissingComponentException
public void setNamespaceResolver(NamespaceResolver resolver)
resolver
- the namespace resolver to be usedpublic boolean testFixedValue(java.lang.CharSequence value, NamespaceResolver resolver) throws ValidationException, MissingComponentException
value
- the value to be testedresolver
- the namespace resolver to be used if the value is namespace sensitiveValidationException
- if the value is not valid for this typeMissingComponentException
public boolean isOptional()
public boolean isProhibited()
public boolean isRequired()
public void setUse(short value)
value
- one of the following:
("prohibited" | "optional" | "required")public void setDefaultValue(java.lang.String value)
value
- the default valuepublic void setFixedValue(AtomicSequence value)
value
- the fixed valuepublic void setFixedValueLexicalForm(java.lang.String value)
value
- the lexical form of the fixed value.public void setInheritable(int inherit)
inherit
- values are 0 (false), 1 (true), -1 (unspecified, use value
from attribute declaration)public boolean isInheritable() throws MissingComponentException
MissingComponentException
public boolean fixup(SchemaCompiler compiler) throws SchemaException
fixup
in interface UserSchemaComponent
fixup
in class SchemaStructure
compiler
- the schema compiler, used for error reportingSchemaException
public boolean validate(SchemaCompiler compiler) throws SchemaException
validate
in interface UserSchemaComponent
SchemaException
- if the error listener decides an error is fatalpublic void serialize(SchemaModelSerializer serializer) throws XPathException
serializer
- the schema serializerXPathException
- if a failure occurspublic Function getComponentAsFunction()
SchemaComponent
getComponentAsFunction
in interface SchemaComponent
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.