Free Trial - Stylus Studio, The World's Best XML IDE!


com.saxonica.schema
Class AttributeDecl

java.lang.Object
  |
  +--com.saxonica.schema.SchemaElement
        |
        +--com.saxonica.schema.AttributeDecl
All Implemented Interfaces:
SchemaComponent, SchemaDeclaration, java.io.Serializable, javax.xml.transform.SourceLocator

public final class AttributeDecl
extends SchemaElement
implements SchemaComponent

An XML Schema Attribute Declaration. This includes global attribute declarations, local attribute declarations, and "attribute uses".

See Also:
Serialized Form

Field Summary
static short OPTIONAL
          Value representing use="optional"
static short PROHIBITED
          Value representing use="prohibited"
static short REQUIRED
          Value representing use="required"
 
Fields inherited from class com.saxonica.schema.SchemaElement
ANNOTATION, ANYTYPE, APPINFO, ATTRIBUTE, ATTRIBUTE_GROUP, COMPLEX_CONTENT, COMPLEX_TYPE, COMPOSITOR, DOCUMENTATION, ELEMENT, FACET, GROUP, IDENTITY_FIELD, IDENTITY_SELECTOR, KEY, KEYREF, LIST, REDEFINE, SCHEMA, SIMPLE_CONTENT, SIMPLE_TYPE, UNION, UNIQUE, UNKNOWN, WILDCARD_ATTRIBUTE, WILDCARD_ELEMENT
 
Constructor Summary
AttributeDecl(Schema schema)
          Creates a new AttrDecl in the given schema.
 
Method Summary
 boolean fixup(Schema schema)
          Fix up references to other elements in the schema.
 java.lang.String getDefaultValue()
          Returns the default value of this attribute declaration.
 int getFingerprint()
          Gets the fingerprint of this attribute name
 Value getFixedValue()
          Returns the fixed value of this attribute declaration.
 java.lang.String getForm()
          Returns the 'form' for this attribute declaration.
 java.lang.String getId()
          Returns the Id for this attribute declaration
 java.lang.String getName()
          Returns the name of the attribute defined by this AttributeDecl.
 AttributeDecl getReference()
          If this is an attribute reference, returns the AttributeDecl that this attribute definition references.
 Schema getSchema()
          Get the Schema that this AttributeDecl belongs to.
 SimpleType getSimpleType()
          Get the type associated with this Attribute Declaration.
 short getStructureType()
          Returns the type of this Schema Structure
 java.lang.String getUse()
          Get the value of the 'use' attribute for this attribute declaration or attribute reference.
 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 isReference()
          Returns true if this attribute definition simply references another attribute Definition
 boolean isRequired()
          Returns true if the 'use' attribute is equal to REQUIRED and there is no specified value.
 void setDefaultValue(java.lang.String value)
          Sets the DEFAULT value.
 void setFingerprint(int fingerprint)
          Set the fingerprint for this attribute name.
 void setFixedValue(Value value)
          Sets the FIXED value.
 void setForm(java.lang.String form)
          Sets the Form for this attribute declaration.
 void setId(java.lang.String id)
          Sets the Id for this attribute declaration.
 void setName(java.lang.String name)
          Sets the name of attributes defined by this attribute definition.
 void setReference(java.lang.String reference)
          Sets the reference for this attribute definition.
 void setSimpleType(SimpleType simpleType)
          Sets the SimpleType for this attribute declaration.
 void setTypeFingerprint(int fingerprint)
          Set the namepool fingerprint of the name of the element's type.
 void setUse(short value)
          Sets the 'use' attribute of this attribute declaration.
 boolean testFixedValue(java.lang.CharSequence value)
          Test a value against the fixed value.
 boolean validate(Schema schema)
          Checks the validity of this Attribute declaration
 
Methods inherited from class com.saxonica.schema.SchemaElement
getColumnNumber, getLineNumber, getPublicId, getSystemId, setLocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPTIONAL

public static final short OPTIONAL
Value representing use="optional"

See Also:
Constant Field Values

PROHIBITED

public static final short PROHIBITED
Value representing use="prohibited"

See Also:
Constant Field Values

REQUIRED

public static final short REQUIRED
Value representing use="required"

See Also:
Constant Field Values
Constructor Detail

AttributeDecl

public AttributeDecl(Schema schema)
Creates a new AttrDecl in the given schema. For system use only.

Parameters:
schema - the schema that contains the new attrDecl
Method Detail

getForm

public java.lang.String getForm()
Returns the 'form' for this attribute declaration. The result specifies whether or not names are qualified or unqualified for instances of this attribute declaration. If null, the form should be obtained from the owning Schema object.

Returns:
the form for this attribute declaration, as a string "qualified" or "unqualified", or null if not set.

getId

public java.lang.String getId()
Returns the Id for this attribute declaration

Returns:
the Id for this attribute declaration (that is, the value of the 'id' attribute if any)

getName

public java.lang.String getName()
Returns the name of the attribute defined by this AttributeDecl. If this AttributeDecl is a reference to another AttributeDecl, the reference will be resolved and the name of the referenced AttributeDecl will be returned. The name will always be an NCName, no namespace prefix will be included.

Returns:
the local name of attributes defined by this AttributeDecl.

setFingerprint

public void setFingerprint(int fingerprint)
Set the fingerprint for this attribute name. For internal use only.


getFingerprint

public int getFingerprint()
Gets the fingerprint of this attribute name

Returns:
the fingerprint of the attribute name in the NamePool

getSimpleType

public SimpleType getSimpleType()
Get the type associated with this Attribute Declaration.

Returns:
the type of this attribute.

getReference

public AttributeDecl getReference()
If this is an attribute reference, returns the AttributeDecl that this attribute definition references. This will return null if this attribute definition does not reference a different attribute definition.

Returns:
the AttributeDecl that this attribute definition references. If validation of this AttributeDecl has failed, this method may return null.

setTypeFingerprint

public void setTypeFingerprint(int fingerprint)
Set the namepool fingerprint of the name of the element's type.


getSchema

public Schema getSchema()
Get the Schema that this AttributeDecl belongs to.

Returns:
the Schema that this AttributeDecl belongs to.

getUse

public java.lang.String 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".

getDefaultValue

public java.lang.String getDefaultValue()
Returns the default value of this attribute declaration.

Returns:
the default value defined by this attribute declaration, or null if no default was specified.

getFixedValue

public Value getFixedValue()
Returns the fixed value of this attribute declaration.

Returns:
the fixed value defined by this attribute declaration, or null if no fixed value was specified. 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.

testFixedValue

public boolean testFixedValue(java.lang.CharSequence value)
                       throws ValidationException
Test a value against the fixed value.

Parameters:
value - the value to be tested
Returns:
true if it matches (or if there is no fixed value), false otherwise
Throws:
ValidationException - if the value is not valid for this type

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".

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

isReference

public boolean isReference()
Returns true if this attribute definition simply references another attribute Definition

Returns:
true if this attribute definition is a reference

setForm

public void setForm(java.lang.String form)
Sets the Form for this attribute declaration. The value species whether or not names are qualified or unqualified for instances of this attribute declaration. If null, the Form is to be obtained from the parent Schema. For internal use only.

Parameters:
form - the form for this attribute declaration, as a string, "qualified" or "unqualified". The caller is responsible for validating the value.

setId

public void setId(java.lang.String id)
Sets the Id for this attribute declaration. For internal use only.

Parameters:
id - the Id for this attribute declaration

setName

public void setName(java.lang.String name)
Sets the name of attributes defined by this attribute definition. For internal use only.

Parameters:
name - the local name of the this AttributeDecl. Must be a valid NCName. It is the caller's responsibility to validate the name.

setReference

public void setReference(java.lang.String reference)
Sets the reference for this attribute definition. For internal use only.

Parameters:
reference - the name of the attribute definition that this definition references

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

setUse

public void setUse(short value)
            throws SchemaException
Sets the 'use' attribute of this attribute declaration. For internal use only.

Parameters:
value - one of the following: ("prohibited" | "optional" | "required")
SchemaException

setDefaultValue

public void setDefaultValue(java.lang.String value)
                     throws SchemaException
Sets the DEFAULT value. For internal use only.

SchemaException

setFixedValue

public void setFixedValue(Value value)
                   throws SchemaException
Sets the FIXED value. For internal use only.

SchemaException

getStructureType

public short getStructureType()
Returns the type of this Schema Structure

Specified by:
getStructureType in class SchemaElement
Returns:
the type of this Schema Structure: always SchemaElement.ATTRIBUTE

fixup

public boolean fixup(Schema schema)
Fix up references to other elements in the schema. This implementation does nothing

Specified by:
fixup in interface SchemaComponent
Parameters:
schema - The schema.
Returns:
true (this implementation does nothing).

validate

public boolean validate(Schema schema)
                 throws javax.xml.transform.TransformerException
Checks the validity of this Attribute declaration

Specified by:
validate in interface SchemaComponent
Parameters:
schema - if this is not null, any errors that are detected should be reported using the error() method of this schema.
Returns:
true when this Schema definition is valid, otherwise false.
Throws:
javax.xml.transform.TransformerException - if the error listener decides an error is fatal


Stylus Studio features integrated development and debugging support for Saxon in the XQuery editor and XSLT editor.