次の方法で共有


<xsd: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 属性を指定できます。

    この値は、修飾名 (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>

その他のリソース

詳細については、www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-all で公開されている、W3C 勧告『XML Schema Part 1: Structures』を参照してください。

参照

リファレンス

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