次の方法で共有


attributeGroup

一連の属性宣言をグループ化して、複合型定義にグループとして組み入れることができるようにします。

<attributeGroup
  id = ID 
  name = NCName
  ref = QName
  {any attributes with non-schema Namespace...}>
Content: (annotation?), ((attribute | attributeGroup)*, anyAttribute?))
</attributeGroup>

属性

  • id
    この要素の ID。id の値は ID 型である必要があり、この要素を含んでいるドキュメント内で一意である必要があります。

    省略可能です。

  • name
    attributeGroup 要素または complexType 要素に含める属性が属する属性グループの名前。この名前は、『XML Namespaces』の仕様に定義されているとおり、コロンを含まない名前 (NCName) である必要があります。name 属性と ref 属性は、同時には使用できません。属性グループが schema 要素の子要素である場合だけ、name 属性を指定できます。

    省略可能です。

  • ref
    attributeGroup 要素または complexType 要素に含める属性が属する属性グループの参照名。

    name 属性と ref 属性は、同時には使用できません。属性グループが schema 要素の子要素ではない場合だけ、ref 属性を指定できます。

    ref の値は、限定名 (QName) である必要があります。

    省略可能です。

要素情報

出現回数 無制限
親要素 attributeGroupcomplexTypeschemarestriction (simpleContent)extension (simpleContent)restriction (complexContent)extension (complexContent)
コンテンツ annotationattributeattributeGroupanyAttribute

解説

属性グループは schema 要素の子要素としてだけ定義できます。属性グループを定義するときは、name 属性を指定し、属性グループを構成する attributeattributeGroupanyAttribute の各要素を含める必要があります。

属性グループは attributeGroup または complexType に含めることができます。このとき、ref 属性を指定し、attributeGroup 要素は空である必要があります。次の例を参照してください。

attributeGroup 要素に、他の attributeGroup 要素を含めることができます。

属性グループ (myAttributeGroup) を定義し、複合型 (myElementType) で使用する例を次に示します。

<xs:attributeGroup name="myAttributeGroup">
    <xs:attribute name="someattribute1" type="xs:integer"/>
    <xs:attribute name="someattribute2" type="xs:string"/>
</xs:attributeGroup>

<xs:complexType name="myElementType">
    <xs:attributeGroup ref="myAttributeGroup"/>
</xs:complexType>

一方の属性グループにもう一方の属性グループが含まれる 2 つの属性グループ (myAttributeGroupA および myAttributeGroupB) を定義する例を次に示します。

<xs:attributeGroup name="myAttributeGroupA">
    <xs:attribute name="someattribute10" type="xs:integer"/>
    <xs:attribute name="someattribute11" type="xs:string"/>
</xs:attributeGroup>

<xs:attributeGroup name="myAttributeGroupB">
    <xs:attribute name="someattribute20" type="xs:date"/>
    <xs:attributeGroup ref="myAttributeGroupA"/>
</xs:attributeGroup>

参照

XML スキーマ リファレンス (XSD) | XML スキーマの要素

詳細については、http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-attributeGroup で、W3C『XML Schema Part 1: Structures Recommendation』を参照してください。