1

というルート ノードを含む XML ファイルを作成したいと考えていますappointment_list。このルート ノードには、 type の子要素が複数含まれている必要がありますappointment_type

以下のスキーマを書きましたが、エラーが発生します。

s4s-elt-must-match.1: 'appointments_list' の内容は (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)) と一致する必要があります。要素から始まる問題が見つかりました。

メッセージにリストされているトークンの 1 つを使用することになっていることはわかっていますが、どのトークンかはわかりません。私はXMLが初めてです。私が望むのは、アポイントメントリストのルート要素に複数の子アポイントメントタイプ要素が含まれていることです。それ、どうやったら出来るの。ありがとう :)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs= "http://www.w3.org/2001/XMLSchema">

    <xs:simpleType name="priority">
        <xs:restriction base="xs:string">
            <xs:enumeration value="high"/>
            <xs:enumeration value="normal"/>
            <xs:enumeration value="low"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="appointment_type">
        <xs:sequence>
            <xs:element name="title" type="xs:string" minOccurs="1" />
            <xs:element name="description" type="xs:string" minOccurs="0"/>
            <xs:element name="appointment_date" type="xs:date" minOccurs="1"/>
            <xs:element name="appointment_time" type="xs:time" minOccurs="1"/>
            <xs:element name="appointment_priority" type="priority" minOccurs="0"/>
            <xs:element name="duration" minOccurs="0">
                <xs:simpleType>
                    <xs:restriction base="xs:integer">
                        <xs:minInclusive value="0"/>
                        <xs:maxInclusive value="24"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="id" type="xs:positiveInteger" use="required"/>
    </xs:complexType>   

    <xs:element name="appointments_list">
            <xs:element name="appointment" type="appointment_type" maxOccurs="unbounded" />
    </xs:element>
</xs:schema>
4

1 に答える 1

3

<xs:element>要素を含む には<xs:complexType>(または、要素のtypeように値が複合型である属性<appointment>) が必要です。

<xs:complexType>はグループが必要<xs:sequence>です。

<xs:element name="appointments_list">
  <xs:complexType>   
    <xs:sequence>   
      <xs:element name="appointment" type="appointment_type" maxOccurs="unbounded" />
    </xs:sequence>   
  </xs:complexType>   
</xs:element>
于 2012-11-19T11:41:37.120 に答える