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


com.saxonica.schema
Class AttributeGroupDecl

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

public final class AttributeGroupDecl
extends AttributeGroup
implements SchemaComponent, CircularityChecker

An XML Schema Attribute Group Declaration. This represents a named attribute group, but not an attribute group reference. As well as attribute groups explicitly written in the schema using xsl:attributeGroup, this class is also used to represent any collection of attributes defined using xsl:attribute elements as part of a complex type definition.

See Also:
Serialized Form

Field Summary
 
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
AttributeGroupDecl(Schema schema)
          Creates a new AttributeGroup definition.
 
Method Summary
 void addAttribute(AttributeDecl attrDecl)
          Adds the given attribute definition to this AttributeGroup.
 void addReference(AttributeGroupReference attrGroup)
          Adds the given AttributeGroupReference to this AttributeGroup.
 boolean fixup(Schema schema)
          Check references from this component to other components
 java.util.Iterator getAttributes()
          Returns an Iterator over all the attributes of this attribute group.
 AttributeWildcard getAttributeWildcard()
          Get the complete attribute wildcard used in this attribute group.
 java.util.Iterator getLocalAttributeGroupReferences()
          Returns the AttributeGroup references contained locally in this attribute group.
 java.util.Iterator getLocalAttributes()
          Returns the attributes defined locally in this attribute group.
 AttributeWildcard getLocalAttributeWildcard()
          Get the local attribute wildcard used in this attribute group
 java.lang.String getName()
          Returns the name of this AttributeGroup
 short getStructureType()
          Returns the type of this Schema Structure
 boolean isEmpty()
          Tests whether this AttributeGroup contains any AttributeDecls or any non-empty AttributeGroups
 boolean isValidRestriction(AttributeGroup base, Schema schema)
          Test whether this attribute group is a valid restriction of another attribute group.
 void lookForCycles(Schema schema, java.util.Stack references)
          Check for cycles in the attribute group.
 void setAnyAttribute(AttributeWildcard wildcard)
          Sets the wildcard (anyAttribute) of this attribute Group.
 void setName(java.lang.String name)
          Sets the name of this AttributeGroup
 void setRedefinedAttributeGroup(AttributeGroupDecl decl)
          Set the attribute group that this one redefines (via xs:redefine).
 boolean validate(Schema schema)
          Checks the validity of this Attribute declaration.
 
Methods inherited from class com.saxonica.schema.AttributeGroup
getAttributeUse, getDeclaredAttributes, getFingerprint, getId, getSchema, setFingerprint, setId, setSchema
 
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
 

Constructor Detail

AttributeGroupDecl

public AttributeGroupDecl(Schema schema)
Creates a new AttributeGroup definition. For internal use only.

Parameters:
schema - the Schema that this AttributeGroup belongs to.
Method Detail

addAttribute

public void addAttribute(AttributeDecl attrDecl)
Adds the given attribute definition to this AttributeGroup. Doesn't throw an error if it's a duplicate: this is left until validation time. For internal use only.

Parameters:
attrDecl - the Attribute Declaration to add

addReference

public void addReference(AttributeGroupReference attrGroup)
Adds the given AttributeGroupReference to this AttributeGroup. For internal use only.

Parameters:
attrGroup - the AttributeGroupReference to add

getLocalAttributes

public java.util.Iterator getLocalAttributes()
Returns the attributes defined locally in this attribute group. (not those of the nested groups)

Returns:
an iterator over the attribute uses defined locally in this attribute group. The objects returned by the iterator are instances of AttributeDecl

getLocalAttributeGroupReferences

public java.util.Iterator getLocalAttributeGroupReferences()
Returns the AttributeGroup references contained locally in this attribute group. (not those of the nested groups)

Returns:
an iterator over the locally-defined attribute groups. The objects returned by this iterator are instances of AttributeGroupReference

setRedefinedAttributeGroup

public void setRedefinedAttributeGroup(AttributeGroupDecl decl)
Set the attribute group that this one redefines (via xs:redefine). For internal use only.

Parameters:
decl - The AttributeDecl object that is redefined

lookForCycles

public void lookForCycles(Schema schema,
                          java.util.Stack references)
                   throws SchemaException
Check for cycles in the attribute group.

Specified by:
lookForCycles in interface CircularityChecker
Overrides:
lookForCycles in class AttributeGroup
Parameters:
schema - The containing schema, used for error reporting
references - The attribute groups that contain direct or indirect references to this attribute group
Throws:
SchemaException - if a circularity is detected.

getLocalAttributeWildcard

public AttributeWildcard getLocalAttributeWildcard()
Get the local attribute wildcard used in this attribute group

Returns:
the wildcard used in this complexType if there is one; otherwise return null.

getAttributeWildcard

public AttributeWildcard getAttributeWildcard()
Get the complete attribute wildcard used in this attribute group. This takes into account any attribute wildcards used in contained attribute groups. The rules are given in Schema Part 1 section 3.4.2. The returned wildcard is the intersection of the attribute wildcards in the various attribute groups: that is, a wildcard that allows only what each one of these wildcards allows.

Specified by:
getAttributeWildcard in class AttributeGroup
Returns:
the combined wildcard used in this attribute group. This can be null. It can also be "inexpressible". This results in an AttributeWildcard marked as being inexpressible, an error condition that the caller is left to deal with.

getAttributes

public java.util.Iterator getAttributes()
Returns an Iterator over all the attributes of this attribute group. The iteration includes attributes from all attribute groups references contained in this AttributeGroup.

Specified by:
getAttributes in class AttributeGroup
Returns:
an Iterator over all the attributes of this attribute group, expanded recursively. The objects returned by this Iterator are AttributeDecl objects.

isEmpty

public boolean isEmpty()
Tests whether this AttributeGroup contains any AttributeDecls or any non-empty AttributeGroups

Returns:
true if this AttributeGroup does not contain any AttributeDecls or any non-empty AttributeGroups

getName

public java.lang.String getName()
Returns the name of this AttributeGroup

Returns:
the name of this AttributeGroup, or null, if no name was defined.

setAnyAttribute

public void setAnyAttribute(AttributeWildcard wildcard)
Sets the wildcard (anyAttribute) of this attribute Group. It is the caller's responsibility to ensure that only one attribute wildcard is defined in an attribute group.


setName

public void setName(java.lang.String name)
Sets the name of this AttributeGroup

Parameters:
name - the name of this AttributeGroup

getStructureType

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

Overrides:
getStructureType in class AttributeGroup
Returns:
the type of this Schema Structure

fixup

public boolean fixup(Schema schema)
              throws SchemaException
Description copied from interface: SchemaComponent
Check references from this component to other components

Specified by:
fixup in interface SchemaComponent
Parameters:
schema - The schema is used for reporting errors
Returns:
true if all is well, false if errors found
SchemaException

validate

public boolean validate(Schema schema)
                 throws javax.xml.transform.TransformerException
Checks the validity of this Attribute declaration. For internal use only. Any errors found are reported to the error listener.

Specified by:
validate in interface SchemaComponent
Parameters:
schema - the containing schema, used for error reporting
Returns:
true if the declaration is valid, false if not
Throws:
SchemaException - if this Attribute declaration is invalid and the error listener chooses to treat the error as fatal.
javax.xml.transform.TransformerException - if the ErrorListener decides that an error is fatal.

isValidRestriction

public boolean isValidRestriction(AttributeGroup base,
                                  Schema schema)
                           throws SchemaException
Test whether this attribute group is a valid restriction of another attribute group. If it is not a valid restriction, an error is reported to the error listener and the method returns false.

Parameters:
base - the other attribute group
schema - the containing schema (used for reporting errors)
Returns:
true if this is a valid restriction, false if not
Throws:
SchemaException - if an error is detected and the error listener decides to treat the error as fatal.


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