Class AttributeGroupDecl

  • All Implemented Interfaces:
    SerializableSchemaComponent, UserSchemaComponent, javax.xml.transform.SourceLocator, Location, SchemaComponent, org.xml.sax.Locator

    public final class AttributeGroupDecl
    extends SchemaStructure
    implements UserSchemaComponent, SerializableSchemaComponent
    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.

    • Constructor Detail

      • AttributeGroupDecl

        public AttributeGroupDecl​(EnterpriseConfiguration config)
        Creates a new AttributeGroup definition. For internal use only.
        config - the EnterpriseConfiguration that this AttributeGroup belongs to.
    • Method Detail

      • getAttributeGroupName

        public StructuredQName getAttributeGroupName()
        Get the name of this attribute group, as a qualified name
        the expanded name of this attribute group
      • getName

        public java.lang.String getName()
        Returns the local part of the name of this named AttributeGroup.
        the local name of this named AttributeGroup.
      • getTargetNamespace

        public NamespaceUri getTargetNamespace()
        Returns the namespace URI of the name of this named AttributeGroup.
        the namespace URI of this named AttributeGroup: null if the attribute group is in no namespace
      • addAttributeUse

        public void addAttributeUse​(AttributeUse use)
        Add the given attribute use to this AttributeGroup. Doesn't throw an error if it's a duplicate: this is left until validation time. For internal use only.
        use - the AttributeUse to add
      • addAttributeGroupReference

        public void addAttributeGroupReference​(AttributeGroupReference attrGroup)
        Adds the given AttributeGroupReference to this AttributeGroup. For internal use only.
        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
        other - the attribute group declaration that this attribute group redefines
      • getLocalAttributes

        public java.util.List<AttributeUse> getLocalAttributes()
        Returns the attributes defined locally in this attribute group. (not those of the nested groups)
        the attribute uses defined locally in this attribute group.
      • getLocalAttributeGroupReferences

        public java.util.List<AttributeGroupReference> getLocalAttributeGroupReferences()
        Returns the AttributeGroup references contained locally in this attribute group. (not those of the nested groups)
        the locally-defined attribute groups.
      • getLocalAttributeWildcard

        public AttributeWildcard getLocalAttributeWildcard()
        Get the local attribute wildcard used in this attribute group
        the wildcard used in this complexType if there is one; otherwise return null.
      • getAttributeWildcard

        public AttributeWildcard getAttributeWildcard​(SchemaCompiler compiler)
        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.
        compiler - Used for error reporting. May be null if used at validation time.
        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.
        MissingComponentException - if a required component contains a reference to another component that is not present in the schema
      • getAttributeUses

        public java.util.List<AttributeUse> getAttributeUses()
                                                      throws MissingComponentException
        Returns a list of all the attribute uses of this attribute group. The list includes attributes from all attribute groups references contained in this AttributeGroup.
        all the attributes of this attribute group, expanded recursively. The list does not include attribute wildcards.
      • getCounterMap

        public IntToIntMap getCounterMap()
        Get the counter map used to map attribute names to positions in an array of counters used during instance validation
        the counter map. This is available at any time after validate() is called. The counter map maps the fingerprints of the attributes defined in this attribute group to a sequence of consecutive integers that can be used to index into an array of counters.
      • getDisplayName

        public java.lang.String getDisplayName()
        Return the name of this AttributeGroup, for display purposes
        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.
        wildcard - the wildcard defining the xs:anyAttribute content of this attribute group, if any.
      • validate

        public boolean validate​(SchemaCompiler compiler)
                         throws SchemaException
        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
        validate in class SchemaStructure
        compiler - used for reporting errors and warnings
        true if the declaration is valid, false if not
        SchemaException - if this Attribute declaration is invalid and the error listener chooses to treat the error as fatal.
      • 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.
        base - the other attribute group
        compiler - user for reporting errors and warnings
        true if this is a valid restriction, false if not
        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 attribute group as another. They are considered to be the same component 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)
        other - the attribute group declaration that we are comparing with
        true if the two attribute group declarations are identical
      • setAttributeGroupName

        public void setAttributeGroupName​(StructuredQName name)
        Set the name of this attribute group. For internal use only.
        name - the name of this attribute group
      • getDeclaredAttributes

        public IntHashMap<AttributeUse> getDeclaredAttributes()
                                                       throws MissingComponentException
        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.
        a map defining the attributes in the attribute group
      • getAttributeUse

        public final AttributeUse getAttributeUse​(StructuredQName attributeName)
                                           throws MissingComponentException
        Get the attribute use with a specific name, if there is one. Otherwise return null.
        attributeName - the expanded name of the required attribute in the name pool.
        the attribute with a given name, from among the transitively-expanded definition of this attribute group.
      • serializeContents

        public void serializeContents​(SchemaModelSerializer serializer)
                               throws XPathException
        Serialize the list of attribute users and wildcard
        serializer - the object to which the information is to be sent
        XPathException - if a failure occurs
      • 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 interface SchemaComponent
        getComponentAsFunction in class SchemaStructure
        the schema component represented as a function from property names to property values.