XML Schema redefine エレメント

定義と使用方法

redefine エレメントは、外部スキーマファイルから取得したシンプルおよび複雑なタイプ、グループ、属性グループを現在のスキーマで再定義することを許可します。

エレメント情報

出現回数 無制限
親エレメント schema
内容 annotation、attributeGroup、complexType、group、simpleType

文法

<redefine
id=ID
schemaLocation=anyURI
any attributes
>
(annotation|(simpleType|complexType|group|attributeGroup))*
</redefine>
属性 説明
id オプション。このエレメントのユニークなIDを指定します。
schemaLocation 必須。schema ドキュメントの場所のURI参照。
any attributes オプション。non-schema ナーミングスペースを持つ他の属性を指定します。

インスタンス

例 1

以下の例では、schema、Myschama2.xsd、が示されています。Myschama1.xsd で定義されたエレメントが存在します。pname タイプが再定義されています。このschemaに基づいて、pnameで制約されているエレメントは「country」エレメントで終わる必要があります:

Myschema1.xsd:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="pname">
  <xs:sequence>
    <xs:element name="firstname"/>
    <xs:element name="lastname"/>
  </xs:sequence>
</xs:complexType>
<xs:element name="customer" type="pname"/>
</xs:schema>

Myschema2.xsd:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:redefine schemaLocation="Myschema1.xsd">
  <xs:complexType name="pname">
    <xs:complexContent>
      <xs:extension base="pname">
        <xs:sequence>
          <xs:element name="country"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:redefine>
<xs:element name="author" type="pname"/>
</xs:schema>