Package com.saxonica.ee.schema
Class AttributeGroupDecl
- java.lang.Object
-
- com.saxonica.ee.schema.SchemaStructure
-
- com.saxonica.ee.schema.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sf.saxon.type.SchemaComponent
SchemaComponent.ValidationStatus
-
-
Field Summary
-
Fields inherited from interface net.sf.saxon.type.SchemaComponent
COMPONENT_FUNCTION_TYPE
-
-
Constructor Summary
Constructors Constructor Description AttributeGroupDecl(EnterpriseConfiguration config)
Creates a new AttributeGroup definition.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributeGroupReference(AttributeGroupReference attrGroup)
Adds the given AttributeGroupReference to this AttributeGroup.void
addAttributeUse(AttributeUse use)
Add the given attribute use to this AttributeGroup.void
buildCounterMap()
Build the counter mapvoid
elaborate(SchemaCompiler compiler)
Elaborate the schema component: after reloading a serialized schema component model, this expands the component with derived information needed during validation episodes.boolean
fixup(SchemaCompiler compiler)
Check references from this component to other componentsStructuredQName
getAttributeGroupName()
Get the name of this attribute group, as a qualified nameAttributeUse
getAttributeUse(StructuredQName attributeName)
Get the attribute use with a specific name, if there is one.java.util.List<AttributeUse>
getAttributeUses()
Returns a list of all the attribute uses of this attribute group.AttributeWildcard
getAttributeWildcard(SchemaCompiler compiler)
Get the complete attribute wildcard used in this attribute group.protected AttributeWildcard
getAttributeWildcard(SchemaCompiler compiler, java.util.Stack<AttributeGroupDecl> stack)
Function
getComponentAsFunction()
Get the schema component in the form of a function item.IntToIntMap
getCounterMap()
Get the counter map used to map attribute names to positions in an array of counters used during instance validationIntHashMap<AttributeUse>
getDeclaredAttributes()
Get a HashMap containing all the attributes in this attribute group, expanded recursively.java.lang.String
getDisplayName()
Return the name of this AttributeGroup, for display purposesjava.util.List<AttributeGroupReference>
getLocalAttributeGroupReferences()
Returns the AttributeGroup references contained locally in this attribute group.java.util.List<AttributeUse>
getLocalAttributes()
Returns the attributes defined locally in this attribute group.AttributeWildcard
getLocalAttributeWildcard()
Get the local attribute wildcard used in this attribute groupjava.lang.String
getName()
Returns the local part of the name of this named AttributeGroup.java.lang.String
getTargetNamespace()
Returns the namespace URI of the name of this named AttributeGroup.boolean
isSameDeclaration(AttributeGroupDecl other)
Test whether this is the same attribute group as another.boolean
isValidRestriction(AttributeGroupDecl base, SchemaCompiler compiler)
Test whether this attribute group is a valid restriction of another attribute group.void
lookForCycles(java.util.Stack references, SchemaCompiler compiler)
Check for cycles in the attribute group.void
serialize(SchemaModelSerializer serializer)
Serialize the schema componentvoid
serializeContents(SchemaModelSerializer serializer)
Serialize the list of attribute users and wildcardvoid
setAnyAttribute(AttributeWildcard wildcard)
Sets the wildcard (anyAttribute) of this attribute Group.void
setAttributeGroupName(StructuredQName name)
Set the name of this attribute group.void
setRedefinedAttributeGroupDecl(AttributeGroupDecl other)
Set the attribute group that this attribute group redefines.boolean
validate(SchemaCompiler compiler)
Check the validity of this AttributeGroup declaration.-
Methods inherited from class com.saxonica.ee.schema.SchemaStructure
getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, 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 net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatus
-
-
-
-
Constructor Detail
-
AttributeGroupDecl
public AttributeGroupDecl(EnterpriseConfiguration config)
Creates a new AttributeGroup definition. For internal use only.- Parameters:
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- Returns:
- the expanded name of this attribute group
-
getName
public java.lang.String getName()
Returns the local part of the name of this named AttributeGroup.- Returns:
- the local name of this named AttributeGroup.
-
getTargetNamespace
public java.lang.String getTargetNamespace()
Returns the namespace URI of the name of this named AttributeGroup.- Returns:
- 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.- Parameters:
use
- the AttributeUse to add
-
addAttributeGroupReference
public void addAttributeGroupReference(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- Parameters:
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)- Returns:
- 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)- Returns:
- the locally-defined attribute groups.
-
lookForCycles
public void lookForCycles(java.util.Stack references, SchemaCompiler compiler) throws SchemaException
Check for cycles in the attribute group.- Specified by:
lookForCycles
in interfaceUserSchemaComponent
- Overrides:
lookForCycles
in classSchemaStructure
- Parameters:
references
- The attribute groups that contain direct or indirect references to this attribute groupcompiler
- used to report errors and warnings- 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)
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:
MissingComponentException
- if a required component contains a reference to another component that is not present in the schema
-
getAttributeWildcard
protected AttributeWildcard getAttributeWildcard(SchemaCompiler compiler, java.util.Stack<AttributeGroupDecl> stack)
-
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.- Returns:
- all the attributes of this attribute group, expanded recursively. The list does not include attribute wildcards.
- Throws:
MissingComponentException
-
getCounterMap
public IntToIntMap getCounterMap()
Get the counter map used to map attribute names to positions in an array of counters used during instance validation- Returns:
- 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- 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.- Parameters:
wildcard
- the wildcard defining the xs:anyAttribute content of this attribute group, if any.
-
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 reporting errors and warnings- Returns:
- true if all is well, false if errors found
- Throws:
SchemaException
-
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 interfaceUserSchemaComponent
- Parameters:
compiler
- used for reporting errors and warnings- 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.
-
buildCounterMap
public void buildCounterMap() throws MissingComponentException
Build the counter map- Throws:
MissingComponentException
-
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 groupcompiler
- user for reporting errors and warnings- 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 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)- Parameters:
other
- the attribute group declaration that we are comparing with- Returns:
- 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.- Parameters:
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.- Returns:
- a map defining the attributes in the attribute group
- Throws:
MissingComponentException
-
getAttributeUse
public final AttributeUse getAttributeUse(StructuredQName attributeName) throws MissingComponentException
Get the attribute use with a specific name, if there is one. Otherwise return null.- Parameters:
attributeName
- 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.
- Throws:
MissingComponentException
-
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
-
serializeContents
public void serializeContents(SchemaModelSerializer serializer) throws XPathException
Serialize the list of attribute users and wildcard- Parameters:
serializer
- the object to which the information is to be sent- Throws:
XPathException
- if a failure occurs
-
elaborate
public void elaborate(SchemaCompiler compiler) throws SchemaException
Elaborate the schema component: after reloading a serialized schema component model, this expands the component with derived information needed during validation episodes. The model is assumed to be valid.- Specified by:
elaborate
in interfaceUserSchemaComponent
- Overrides:
elaborate
in classSchemaStructure
- Parameters:
compiler
- the schema compiler- Throws:
SchemaException
-
getComponentAsFunction
public Function 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
- Returns:
- the schema component represented as a function from property names to property values.
-
-