XML スキーマ: テキストのみを含む属性を持つ要素? 質問する

XML スキーマ: テキストのみを含む属性を持つ要素? 質問する

これを探すのに苦労しています。次のような XML の XML スキーマ ファイル内の要素をどのように定義すればよいでしょうか。

<option value="test">sometext</option>

xs:string型であり、属性も持つ要素を定義する方法がわかりません。

これまでに得たものは次のとおりです。

<xs:element name="option">
    <xs:complexType>
        <xs:attribute name="value" type="xs:string" />
    </xs:complexType>
</xs:element>

ベストアンサー1

試す

  <xs:element name="option" type="AttrElement" />

  <xs:complexType name="AttrElement">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="value" type="xs:string">
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

おすすめ記事