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"
|
nameCode, 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 |
FunctionItem |
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
|
String |
getDefaultValue()
Returns the default value of this attribute use.
|
String |
getDisplayName()
Returns the name of the attribute defined by this AttributeDecl.
|
AtomicSequence |
getFixedValue()
Returns the fixed value of this attribute use.
|
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.
|
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(String value)
Sets the default value.
|
void |
setFixedValue(AtomicSequence value)
Sets 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(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
|
getFingerprint, getNameCode, getSymbolSpace, getTarget, isResolved, setNameCode, setTarget
elaborate, getColumnNumber, getConfiguration, getFixupStatus, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, lookForCycles, makeXPathExpressionPropertyRecord, setConfiguration, setFixupStatus, 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
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 UnresolvedReferenceException
UnresolvedReferenceException
- 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 String getDisplayName()
public String getUse()
public int getCardinality()
StaticProperty.EXACTLY_ONE
, StaticProperty.EMPTY
, or
StaticProperty.ALLOWS_ZERO_OR_ONE
public String getDefaultValue()
public String getUnderlyingDefaultValue()
public AtomicSequence getFixedValue()
public AtomicSequence getUnderlyingFixedValue()
public void setNamespaceResolver(NamespaceResolver resolver)
resolver
- the namespace resolver to be usedpublic boolean testFixedValue(CharSequence value, NamespaceResolver resolver) throws ValidationException
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 typepublic boolean isOptional()
public boolean isProhibited()
public boolean isRequired()
public void setUse(short value)
value
- one of the following:
("prohibited" | "optional" | "required")public void setDefaultValue(String value)
value
- the default valuepublic void setFixedValue(AtomicSequence value)
value
- the fixed valuepublic void setInheritable(int inherit)
inherit
- values are 0 (false), 1 (true), -1 (unspecified, use value
from attribute declaration)public boolean isInheritable()
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 FunctionItem getComponentAsFunction()
SchemaComponent
getComponentAsFunction
in interface SchemaComponent
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.