Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.saxonica.schema
Class AttributeGroupDecl

    java.lang.Object
      com.saxonica.schema.SchemaStructure
          com.saxonica.schema.AttributeGroupDecl

All Implemented Interfaces:
  SerializableSchemaComponent, UserSchemaComponent, Serializable, SourceLocator, SchemaComponent

    public final class AttributeGroupDecl

extends SchemaStructure
implements UserSchemaComponent

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.

In contrast with the Attribute Group Definition schema component as defined in the W3C specification, the model retains explicit references to subsidiary attribute group definitions. However, the method `getAttributeUses()` performs the transitive closure of these references, returning all the attributes at the leaves of the tree.

See Also:
  Serialized Form

Field Summary

Fields inherited from interface net.sf.saxon.type.SchemaComponent
`FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING`

Fields inherited from interface com.saxonica.schema.SerializableSchemaComponent
`ALL_COMPOSITOR, ATOMIC_TYPE, ATTRIBUTE_DECL, ATTRIBUTE_GROUP, ATTRIBUTE_GROUP_REF, ATTRIBUTE_USE, ATTRIBUTE_WILDCARD, CHOICE_COMPOSITOR, COMPLEX_TYPE, ELEMENT_DECL, ELEMENT_PARTICLE, ELEMENT_WILDCARD, FACET, KEY, KEYREF, LIST_TYPE, MODEL_GROUP, MODEL_GROUP_REF, NOTATION, SEQUENCE_COMPOSITOR, UNION_TYPE, UNIQUE`

Constructor Summary
`AttributeGroupDecl(SchemaAwareConfiguration config)` Creates a new AttributeGroup definition.

Method Summary
`void` | `addAttribute(AttributeUse attrDecl)` Adds the given attribute definition to this AttributeGroup.
`void` | `addReference(AttributeGroupReference attrGroup)` Adds the given AttributeGroupReference to this AttributeGroup.
`boolean` | `fixup(SchemaCompiler compiler)` Check references from this component to other components
`void` | `gatherAttributeUses(List list)` Append all attribute declarations contained directly or indirectly in this attribute group to a supplied List.
`AttributeUse` | `getAttributeUse(int fingerprint)` Get the attribute use with a specific name, if there is one.
`Iterator` | `getAttributeUses()` Returns an Iterator over all the attribute uses of this attribute group.
`AttributeWildcard` | `getAttributeWildcard(SchemaCompiler compiler)` Get the complete attribute wildcard used in this attribute group.
`int` | `getComponentTypeCode()` Get a unique number identifying the type of component
`IntHashMap` | `getDeclaredAttributes()` Get a HashMap containing all the attributes in this attribute group, expanded recursively.
`String` | `getDisplayName()` Return the name of this AttributeGroup, for display purposes
`int` | `getFingerprint()` Get the fingerprint of the name of the attribute group
`Iterator` | `getLocalAttributeGroupReferences()` Returns the AttributeGroup references contained locally in this attribute group.
`Iterator` | `getLocalAttributes()` Returns the attributes defined locally in this attribute group.
`AttributeWildcard` | `getLocalAttributeWildcard()` Get the local attribute wildcard used in this attribute group
`PreparedSchema` | `getSchema()` Get the schema in which this attribute group is defined.
`boolean` | `isSameDeclaration(AttributeGroupDecl other)` Test whether this is the same type as another type.
`boolean` | `isValidRestriction(AttributeGroupDecl base, SchemaCompiler compiler)` Test whether this attribute group is a valid restriction of another attribute group.
`void` | `lookForCycles(Stack references, SchemaCompiler compiler)` Check for cycles in the attribute group.
`void` | `serialize(SchemaSerializer serializer)` Serialize the schema component
`void` | `setAnyAttribute(AttributeWildcard wildcard)` Sets the wildcard (anyAttribute) of this attribute Group.
`void` | `setNameCode(int nameCode)` Set the nameCode of the name of this attribute group.
`void` | `setRedefinedAttributeGroupDecl(AttributeGroupDecl other)` Set the attribute group that this attribute group redefines.
`void` | `setSchema(PreparedSchema schema)` Set the schema that this attribute group belongs to.
`boolean` | `validate(SchemaCompiler compiler)` Check the validity of this AttributeGroup declaration.

Methods inherited from class com.saxonica.schema.SchemaStructure
`getColumnNumber, getConfiguration, getFixupStatus, getLineNumber, getPublicId, getSystemId, getValidationStatus, setConfiguration, setFixupStatus, setLineNumber, setLocator, setSystemId, setValidationStatus`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface net.sf.saxon.type.SchemaComponent
`getValidationStatus`

Constructor Detail

### AttributeGroupDecl

    public AttributeGroupDecl(SchemaAwareConfiguration config)

  Creates a new AttributeGroup definition. For internal use only.

  Parameters:
    `config` - the SchemaAwareConfiguration that this AttributeGroup belongs to.

Method Detail

### addAttribute

    public void addAttribute(AttributeUse 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

### setRedefinedAttributeGroupDecl

    public void setRedefinedAttributeGroupDecl(AttributeGroupDecl other)

  Set the attribute group that this attribute group redefines. This is called only for an attribute group that redefined another one, *without* a self-reference

### getLocalAttributes

    public 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 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`

### lookForCycles

    public void lookForCycles(Stack references,
                              SchemaCompiler compiler)
                       throws SchemaException

  Check for cycles in the attribute group.

  Specified by:
    `lookForCycles` in interface `UserSchemaComponent`
  Overrides:
    `lookForCycles` in class `SchemaStructure`
  Parameters:
    `references` - The attribute groups that contain direct or indirect references to this attribute group
    `compiler` -
  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(SchemaCompiler compiler)
                                           throws UnresolvedReferenceException

  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.

  Parameters:
    `compiler` - Used for error reporting. May be null if used at validation time.
  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.
  Throws:
    `UnresolvedReferenceException`

### getAttributeUses

    public Iterator getAttributeUses()

  Returns an Iterator over all the attribute uses of this attribute group. The iteration includes attributes from all attribute groups references contained in this AttributeGroup.

  Returns:
    an Iterator over all the attributes of this attribute group, expanded recursively. The objects returned by this Iterator are `AttributeDecl` objects. The iterator does not include attribute wildcards.

### gatherAttributeUses

    public void gatherAttributeUses(List list)

  Append all attribute declarations contained directly or indirectly in this attribute group to a supplied List. The AttributeGroupDecl must have been validated before this method is called.

### getDisplayName

    public String getDisplayName()

  Return the name of this AttributeGroup, for display purposes

  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.

### fixup

    public boolean fixup(SchemaCompiler compiler)
                  throws SchemaException

  Check references from this component to other components

  Specified by:
    `fixup` in interface `UserSchemaComponent`
  Parameters:
    `compiler` -
  Returns:
    true if all is well, false if errors found
  Throws:
    `SchemaException`

### validate

    public boolean validate(SchemaCompiler compiler)
                     throws SchemaException,
                            ValidationException

  Check the validity of this AttributeGroup declaration. For internal use only. Any errors found are reported to the error listener.

  Specified by:
    `validate` in interface `UserSchemaComponent`
  Parameters:
    `compiler` -
  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.
    `ValidationException`

### isValidRestriction

    public boolean isValidRestriction(AttributeGroupDecl base,
                                      SchemaCompiler compiler)
                               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
  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.

### isSameDeclaration

    public boolean isSameDeclaration(AttributeGroupDecl other)

  Test whether this is the same type as another type. They are considered to be the same type if they are derived from the same type definition in the original XML representation (which can happen when there are multiple includes of the same file)

### getFingerprint

    public int getFingerprint()

  Get the fingerprint of the name of the attribute group

  Returns:
    the NamePool fingerprint of the attribute group's expanded name

### setNameCode

    public void setNameCode(int nameCode)

  Set the nameCode of the name of this attribute group. For internal use only.

  Parameters:
    `nameCode` - the fingerprint of the name, in the NamePool

### setSchema

    public void setSchema(PreparedSchema schema)

  Set the schema that this attribute group belongs to. For internal use only.

  Parameters:
    `schema` - the owning schema

### getSchema

    public PreparedSchema getSchema()

  Get the schema in which this attribute group is defined. May return null in the case of a synthetic attribute group that is not actually defined in a schema

  Returns:
    the containing schema

### getDeclaredAttributes

    public IntHashMap getDeclaredAttributes()

  Get a HashMap containing all the attributes in this attribute group, expanded recursively. The key is the integer fingerprint identifying the name of the attribute. The value is an AttributeUse object identifying the attribute declaration.

### getAttributeUse

    public final AttributeUse getAttributeUse(int fingerprint)

  Get the attribute use with a specific name, if there is one. Otherwise return null.

  Parameters:
    `fingerprint` - the fingerprint identifying the expanded name of the required attribute in the name pool.
  Returns:
    the attribute with a given name, from among the transitively-expanded definition of this attribute group.

### serialize

    public void serialize(SchemaSerializer serializer)
                   throws IOException

  Serialize the schema component

  Specified by:
    `serialize` in interface `SerializableSchemaComponent`
  Throws:
    `IOException`

### getComponentTypeCode

    public int getComponentTypeCode()

  Get a unique number identifying the type of component

  Specified by:
    `getComponentTypeCode` in interface `SerializableSchemaComponent`

Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) Michael H. Kay. All rights reserved.