Package com.saxonica.ee.schema
Class AttributeUse
java.lang.Object
com.saxonica.ee.schema.SchemaStructure
com.saxonica.ee.schema.SimpleComponentReference
com.saxonica.ee.schema.AttributeUse
- All Implemented Interfaces:
ComponentReference,ComponentWithValueConstraint,UserSchemaComponent,SourceLocator,Location,SchemaComponent,Locator
public final class AttributeUse
extends SimpleComponentReference
implements ComponentWithValueConstraint, UserSchemaComponent
An XML Schema Attribute Use: that is, a reference to an attribute declaration
from within a complex type or attribute group.
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.
-
Field Summary
Fields inherited from class com.saxonica.ee.schema.SimpleComponentReference
symbolSpace, target -
Constructor Summary
ConstructorsConstructorDescriptionAttributeUse(EnterpriseConfiguration config) Creates a new Attribute Use in the given schema. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfixup(SchemaCompiler compiler) Fix up references to other elements in the schema.Get the corresponding attribute declarationintGet the value of the "use" attribute, expressed as a Cardinality value ofStaticProperty.EXACTLY_ONE,StaticProperty.EMPTY, orStaticProperty.ALLOWS_ZERO_OR_ONEGet the schema component in the form of a function item.Get the attribute group declaration containing this attribute use, if anyReturns the name of the attribute defined by this AttributeDecl.Get the namespace resolver used when the fixed or value constraints include lexical QNamesGet 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 nullReturns the fixed value of this attribute use, or of the corresponding attribute declaration if the attribute use has no fixed value.getUse()Get the value of the 'use' attribute for this attribute declaration or attribute reference.Get the value constraint (fixed or default value) that applies to this element declaration, if anybooleanAsk whether this attribute is inheritablebooleanReturns true if the use attribute is equal to "optional".booleanReturns true if the use attribute is equal to "prohibited".booleanReturns true if the 'use' attribute is equal to REQUIRED and there is no specified value.voidserialize(SchemaModelSerializer serializer) Serialize the schema componentvoidsetContainingAttributeGroupDecl(AttributeGroupDecl containingAttributeGroupDecl) Set the attribute group declaration containing this attribute use, if anyvoidsetInheritable(int inherit) Say whether this attribute is inheritablevoidsetNamespaceResolver(NamespaceResolver resolver) Set the namespace resolver for resolving QName-valued fixed and default valuesvoidsetUse(Optionality value) Sets the 'use' attribute of this attribute declaration.voidSet the value constraint (fixed or default value) that applies to this element declarationvoidtryToResolve(SchemaCompiler compiler, boolean fatal) Attempt to resolve this reference using the components defined in a given schema.booleanvalidate(SchemaCompiler compiler) Checks the validity of this Attribute UseMethods inherited from class com.saxonica.ee.schema.SimpleComponentReference
getSymbolSpace, getTarget, getTargetComponentName, getTargetFingerprint, isDangling, isResolved, setTarget, setTargetComponentNameMethods inherited from class com.saxonica.ee.schema.SchemaStructure
elaborate, getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, lookForCycles, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.saxonica.ee.schema.ComponentReference
getConfigurationMethods inherited from interface com.saxonica.ee.schema.ComponentWithValueConstraint
getDefaultValue, getDefaultValueConstraint, getDefaultValueLexicalForm, getFixedValue, getFixedValueConstraint, getFixedValueLexicalForm, getValueConstraintAsFunctionMethods inherited from interface net.sf.saxon.s9api.Location
getColumnNumber, getLineNumber, getPublicId, getSystemId, saveLocationMethods inherited from interface net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatusMethods inherited from interface com.saxonica.ee.schema.UserSchemaComponent
elaborate, lookForCycles
-
Constructor Details
-
AttributeUse
Creates a new Attribute Use in the given schema. For system use only.- Parameters:
config- the Configuration that contains the new attributeUse
-
-
Method Details
-
tryToResolve
Description copied from class:SimpleComponentReferenceAttempt to resolve this reference using the components defined in a given schema. No error results if the reference cannot be resolved.- Specified by:
tryToResolvein interfaceComponentReference- Overrides:
tryToResolvein classSimpleComponentReference- Parameters:
compiler- The compiler being used to compile the referring component.fatal- True if a failure to resolve should be treated as fatal, irrespective of any settings in the SchemaCompiler- Throws:
SchemaException- if the reference cannot be resolved or repaired.
-
getAttributeDeclaration
Get the corresponding attribute declaration- Returns:
- the attribute declaration referenced by this attribute use
- Throws:
MissingComponentException- if the reference from the AttributeUse to the AttributeDecl has not been resolved
-
getContainingAttributeGroupDecl
Get the attribute group declaration containing this attribute use, if any- Returns:
- the containing attribute declaration, or null
-
setContainingAttributeGroupDecl
Set the attribute group declaration containing this attribute use, if any- Parameters:
containingAttributeGroupDecl- the containing attribute declaration, or null
-
getDisplayName
Returns the name of the attribute defined by this AttributeDecl. This is used only for diagnostic display purposes- Returns:
- the name of the attribute as a lexical QName.
-
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
-
getUse
Get the value of the 'use' attribute for this attribute declaration or attribute reference. If this is a reference the value of the use attribute will *not* be obtained from the referenced attribute declaration as top-level attributes do not take into account the use attribute.- Returns:
- the value of the 'use' attribute for this attribute declaration, as a string: "prohibited", "required", or "optional".
-
getCardinality
public int getCardinality()Get the value of the "use" attribute, expressed as a Cardinality value ofStaticProperty.EXACTLY_ONE,StaticProperty.EMPTY, orStaticProperty.ALLOWS_ZERO_OR_ONE- Returns:
- the cardinality implied by the "use" attribute. If the attribute is optional but either the attribute use or the corresponding attribute declaration defines a default or fixed value, then it is treated as optional (zero-or-one), because we don't know whether fixed/default attribute values are being reported to the application or not: see bug 3072.
-
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
-
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- Returns:
- the default attribute value if there is one, otherwise null
- Throws:
MissingComponentException
-
getUnderlyingFixedValue
Returns the fixed value of this attribute use, or of the corresponding attribute declaration if the attribute use has no fixed value.- Returns:
- the fixed value defined by this attribute use, if one was specified; failing that, the fixed value defined for the corresponding attribute declaration; failing that, null. Once the schema has been compiled this will be the correctly-typed value; until then it will be the string value as specified in the source schema.
- Throws:
MissingComponentException
-
setNamespaceResolver
Set the namespace resolver for resolving QName-valued fixed and default values- Parameters:
resolver- the namespace resolver to be used
-
isOptional
public boolean isOptional()Returns true if the use attribute is equal to "optional".- Returns:
- true if the use attribute is equal to "optional".
-
isProhibited
public boolean isProhibited()Returns true if the use attribute is equal to "prohibited". Note that in the W3C schema component model, no attribute use ever has the value "prohibited": this should be treated as if the attribute use did not exist.- Returns:
- true if the use attribute is equal to "prohibited".
-
isRequired
public boolean isRequired()Returns true if the 'use' attribute is equal to REQUIRED and there is no specified value. If a value is specified and the 'use' attribute is "required" then required is will return false, because the attribute value automatically becomes fixed.- Returns:
- true if the use attribute is equal to "required" and no default value has been specified, otherwise false
-
setUse
Sets the 'use' attribute of this attribute declaration. For internal use only.- Parameters:
value- one of the following: ("prohibited" | "optional" | "required")
-
setValueConstraint
Set the value constraint (fixed or default value) that applies to this element declaration- Specified by:
setValueConstraintin interfaceComponentWithValueConstraint- Parameters:
vc- the value constraint
-
setInheritable
public void setInheritable(int inherit) Say whether this attribute is inheritable- Parameters:
inherit- values are 0 (false), 1 (true), -1 (unspecified, use value from attribute declaration)
-
isInheritable
Ask whether this attribute is inheritable- Returns:
- true if it is inheritable
- Throws:
MissingComponentException
-
fixup
Fix up references to other elements in the schema.- Specified by:
fixupin interfaceUserSchemaComponent- Overrides:
fixupin classSchemaStructure- Parameters:
compiler- the schema compiler, used for error reporting- Returns:
- true if successful.
- Throws:
SchemaException
-
validate
Checks the validity of this Attribute Use- Specified by:
validatein interfaceUserSchemaComponent- Overrides:
validatein classSchemaStructure- Parameters:
compiler- the schema compiler- Returns:
- true when this Schema definition is valid, otherwise false.
- Throws:
SchemaException- if the error listener decides an error is fatal
-
serialize
Serialize the schema component- Parameters:
serializer- the schema serializer- Throws:
XPathException- if a failure occurs
-
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.
-