Package com.saxonica.ee.schema
Class AttributeDecl
- java.lang.Object
-
- com.saxonica.ee.schema.SchemaStructure
-
- com.saxonica.ee.schema.AttributeDecl
-
- All Implemented Interfaces:
ComponentWithValueConstraint
,SerializableSchemaComponent
,UserSchemaComponent
,javax.xml.transform.SourceLocator
,Location
,SchemaComponent
,SchemaDeclaration
,org.xml.sax.Locator
public final class AttributeDecl extends SchemaStructure implements ComponentWithValueConstraint, UserSchemaComponent, SerializableSchemaComponent, SchemaDeclaration
An XML Schema Attribute Declaration. This includes global attribute declarations, local attribute declarations, and "attribute uses". It corresponds to either (a) an attribute declaration schema component for a global attribute, or (b) an attribute declaration schema component for a local attribute, plus an attribute use referencing that attribute declaration, or (c) an attribute use referencing a global attribute declaration.
-
-
Constructor Summary
Constructors Constructor Description AttributeDecl(EnterpriseConfiguration config, boolean global)
Creates a new AttrDecl in the given schema.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
fixup(SchemaCompiler compiler)
Check references from this component to other componentsFunctionItem
getComponentAsFunction()
Get the schema component in the form of a function item.StructuredQName
getComponentName()
Get the attribute nameAttributeGroupDecl
getContainingAttributeGroup()
Get the containing attribute group.UserComplexType
getContainingComplexType()
Get the containing complex type.java.lang.String
getDisplayName()
Returns the name of the attribute defined by this AttributeDecl.int
getFingerprint()
Gets the fingerprint of this attribute namejava.lang.String
getName()
Get the local name of this Attribute Declaration.NamespaceResolver
getNamespaceResolver()
Get the namespace resolver used when the fixed or value constraints include lexical QNamesSimpleType
getSimpleType()
Get the type associated with this Attribute Declaration.NamespaceUri
getTargetNamespace()
Get the namespace URI of this element declaration.SimpleType
getType()
Get the type of this attribute declaration.ValueConstraint
getValueConstraint()
Get the value constraint (fixed or default value) that applies to this element declaration, if anyboolean
hasTypeAlternatives()
Determine, in the case of an Element Declaration, whether there are type alternatives definedboolean
isAbstract()
Determine, in the case of an Element Declaration, whether it is nillable.boolean
isGlobal()
Determine whether this attribute declaration is global.boolean
isInheritable()
Ask whether this attribute is inheritableboolean
isNillable()
Determine, in the case of an Element Declaration, whether it is nillable.boolean
isSameDeclaration(AttributeDecl other)
Test whether this is the same declaration as another attribute declaration.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
serialize(SchemaModelSerializer serializer)
Serialize the schema componentvoid
setAttributeName(StructuredQName attributeName)
Set the attribute name.void
setAttributeName(StructuredQName attributeName, int fingerprint)
Set the attribute name.void
setContainingAttributeGroup(AttributeGroupDecl type)
Sets the containing attribute group definition.void
setContainingComplexType(UserComplexType type)
Sets the containing complex type definition.void
setInheritable(boolean inherit)
Say whether this attribute is inheritablevoid
setNamespaceResolver(NamespaceResolver resolver)
Set the namespace resolver for resolving QName-valued fixed and default valuesvoid
setSimpleType(SimpleType simpleType)
Sets the SimpleType for this attribute declaration.void
setTypeReference(TypeReference type)
Sets the schema type for this attribute declaration.void
setValueConstraint(ValueConstraint vc)
Set the value constraint (fixed or default value) that applies to this element declarationboolean
validate(SchemaCompiler compiler)
Checks the validity of this Attribute declaration-
Methods 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, setValidationStatus
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.saxonica.ee.schema.ComponentWithValueConstraint
getDefaultValue, getDefaultValueConstraint, getDefaultValueLexicalForm, getFixedValue, getFixedValueConstraint, getFixedValueLexicalForm, getValueConstraintAsFunction
-
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatus
-
Methods inherited from interface com.saxonica.ee.schema.UserSchemaComponent
elaborate, lookForCycles
-
-
-
-
Constructor Detail
-
AttributeDecl
public AttributeDecl(EnterpriseConfiguration config, boolean global)
Creates a new AttrDecl in the given schema. For system use only.- Parameters:
config
- the configuration that contains the new attrDeclglobal
- true if the attribute declaration is global
-
-
Method Detail
-
isGlobal
public boolean isGlobal()
Determine whether this attribute declaration is global. This represents one aspect of the {scope} property defined in the schema data model.- Returns:
- true if the attribute declaration is global, false if it is local
-
setContainingComplexType
public void setContainingComplexType(UserComplexType type)
Sets the containing complex type definition. For internal use only.- Parameters:
type
- the containing complex type
-
getContainingComplexType
public UserComplexType getContainingComplexType()
Get the containing complex type. This represents one aspect of the {scope} property defined in the schema component model. If the attribute is a local attribute declaration and is defined as part of a complex type (and not as part of a named attribute group), returns the complex type definition. Otherwise, returns null.- Returns:
- the containing complex type definition if there is one, otherwise null
-
setContainingAttributeGroup
public void setContainingAttributeGroup(AttributeGroupDecl type)
Sets the containing attribute group definition. For internal use only.- Parameters:
type
- the containing attribute group
-
getContainingAttributeGroup
public AttributeGroupDecl getContainingAttributeGroup()
Get the containing attribute group. This represents one aspect of the {scope} property defined in the schema component model. If the attribute is a local attribute declaration and is defined as part of an attribute group (and not as part of a complex type), returns the attribute group. Otherwise, returns null.- Returns:
- the containing attribute group if there is one, otherwise null
-
getName
public java.lang.String getName()
Get the local name of this Attribute Declaration. This corresponds to the {name} property as defined in the schema component model.- Returns:
- the local name of the attribute
-
getTargetNamespace
public NamespaceUri getTargetNamespace()
Get the namespace URI of this element declaration. This corresponds to the {targetNamespace} property defined in the schema component model.- Returns:
- the target namespace URI
-
getDisplayName
public java.lang.String 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.
-
setAttributeName
public void setAttributeName(StructuredQName attributeName, int fingerprint)
Set the attribute name. For internal use only.- Parameters:
attributeName
- the attribute name.fingerprint
- the fingerprint of the attribute name
-
setAttributeName
public void setAttributeName(StructuredQName attributeName)
Set the attribute name. For internal use only.- Parameters:
attributeName
- the attribute name.
-
getComponentName
public StructuredQName getComponentName()
Get the attribute name- Specified by:
getComponentName
in interfaceSchemaDeclaration
- Returns:
- the name of the attribute being declared
-
getNamespaceResolver
public NamespaceResolver getNamespaceResolver()
Description copied from interface:ComponentWithValueConstraint
Get the namespace resolver used when the fixed or value constraints include lexical QNames- Specified by:
getNamespaceResolver
in interfaceComponentWithValueConstraint
- Returns:
- the namespace resolver for lexical QNames
-
setTypeReference
public void setTypeReference(TypeReference type)
Sets the schema type for this attribute declaration. For internal use only.- Parameters:
type
- the schema type for this element declaration.
-
getFingerprint
public int getFingerprint()
Gets the fingerprint of this attribute name- Specified by:
getFingerprint
in interfaceSchemaDeclaration
- Returns:
- the fingerprint of the attribute name in the NamePool
-
getSimpleType
public SimpleType getSimpleType() throws MissingComponentException
Get the type associated with this Attribute Declaration.- Returns:
- the type of this attribute.
- Throws:
MissingComponentException
- if the reference from the attribute declaration to its type has not been resolved
-
getType
public SimpleType getType() throws MissingComponentException
Get the type of this attribute declaration. This corresponds to the {typeDefinition} property defined in the schema component model- Specified by:
getType
in interfaceSchemaDeclaration
- Returns:
- the type of this attribute. The returned SchemaType will
always be an instanceof
SimpleType
- Throws:
MissingComponentException
-
getValueConstraint
public ValueConstraint getValueConstraint()
Get the value constraint (fixed or default value) that applies to this element declaration, if any- Specified by:
getValueConstraint
in interfaceComponentWithValueConstraint
- Returns:
- the applicable value constraint if there is one, or null otherwise
-
setSimpleType
public void setSimpleType(SimpleType simpleType)
Sets the SimpleType for this attribute declaration. For internal use only.- Parameters:
simpleType
- the SimpleType for this attribute declaration
-
setValueConstraint
public void setValueConstraint(ValueConstraint vc)
Set the value constraint (fixed or default value) that applies to this element declaration- Specified by:
setValueConstraint
in interfaceComponentWithValueConstraint
- Parameters:
vc
- the value constraint
-
setNamespaceResolver
public void setNamespaceResolver(NamespaceResolver resolver)
Set the namespace resolver for resolving QName-valued fixed and default values- Parameters:
resolver
- the namespace resolver
-
makeSchemaNodeTest
public NodeTest makeSchemaNodeTest() throws MissingComponentException
Create a NodeTest that implements the semantics of schema-element(name) or schema-attribute(name) applied to this element or attribute declaration.- Specified by:
makeSchemaNodeTest
in interfaceSchemaDeclaration
- Throws:
MissingComponentException
- if the type of the declaration is not present in the schema.
-
setInheritable
public void setInheritable(boolean inherit)
Say whether this attribute is inheritable- Parameters:
inherit
- true if it is inheritable
-
isInheritable
public boolean isInheritable()
Ask whether this attribute is inheritable- Returns:
- true if it is inheritable
-
hasTypeAlternatives
public boolean hasTypeAlternatives()
Determine, in the case of an Element Declaration, whether there are type alternatives defined- Specified by:
hasTypeAlternatives
in interfaceSchemaDeclaration
- Returns:
- false for an attribute declaration
-
fixup
public boolean fixup(SchemaCompiler compiler) throws SchemaException
Check references from this component to other components- Specified by:
fixup
in interfaceUserSchemaComponent
- Overrides:
fixup
in classSchemaStructure
- Parameters:
compiler
- used for error reporting- Returns:
- true if all is well, false if errors found
- Throws:
SchemaException
-
validate
public boolean validate(SchemaCompiler compiler) throws SchemaException
Checks the validity of this Attribute declaration- Specified by:
validate
in interfaceUserSchemaComponent
- Overrides:
validate
in 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
-
isSameDeclaration
public boolean isSameDeclaration(AttributeDecl other)
Test whether this is the same declaration as another attribute declaration. They are considered to be the same declaration if they came from the same xs:attribute element in the same schema document- Parameters:
other
- the other attribute declaration- Returns:
- true if the two attribute declarations are considered identical
-
isNillable
public boolean isNillable()
Determine, in the case of an Element Declaration, whether it is nillable. For an Attribute declaration, always return false;- Specified by:
isNillable
in interfaceSchemaDeclaration
-
isAbstract
public boolean isAbstract()
Determine, in the case of an Element Declaration, whether it is nillable. For an Attribute declaration, always return false;- Specified by:
isAbstract
in interfaceSchemaDeclaration
-
serialize
public void serialize(SchemaModelSerializer serializer) throws XPathException
Serialize the schema component- Specified by:
serialize
in interfaceSerializableSchemaComponent
- Parameters:
serializer
- the object responsible for performing the serialization- Throws:
XPathException
- if serialization fails
-
getComponentAsFunction
public FunctionItem getComponentAsFunction()
Description copied from interface:SchemaComponent
Get 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:
getComponentAsFunction
in interfaceSchemaComponent
- Overrides:
getComponentAsFunction
in classSchemaStructure
- Returns:
- the schema component represented as a function from property names to property values.
-
-