2
XSDファイルを使用してxmlファイルを検証しようとしているときに、The Content Of 'all' Must Match (annotation?, Element*). A Problem Was Found Starting At: Sequence.
というエラーが表示されます。サブルートノードでsize
の番号が変更される可能性があるため、<xs:all>
を使用しました。また、属性タグを<xs:all>
タグの前後に追加するかどうかはわかりません。エラー: 'all'の内容が一致する必要があります
これは私のxmlファイル
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<product description="Cardigan Sweater" product_image="cardigan.jpg">
<catalog_item gender="Men's">
<item_number>QWZ5671</item_number>
<price>39.95</price>
<size description="Medium">
<color_swatch image="red_cardigan.jpg">Red</color_swatch>
<color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
</size>
<size description="Large">
<color_swatch image="red_cardigan.jpg">Red</color_swatch>
<color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
</size>
</catalog_item>
<catalog_item gender="Women's">
<item_number>RRX9856</item_number>
<price>42.50</price>
<size description="Small">
<color_swatch image="red_cardigan.jpg">Red</color_swatch>
<color_swatch image="navy_cardigan.jpg">Navy</color_swatch>
<color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
</size>
<size description="Medium">
<color_swatch image="red_cardigan.jpg">Red</color_swatch>
<color_swatch image="navy_cardigan.jpg">Navy</color_swatch>
<color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
<color_swatch image="black_cardigan.jpg">Black</color_swatch>
</size>
<size description="Large">
<color_swatch image="navy_cardigan.jpg">Navy</color_swatch>
<color_swatch image="black_cardigan.jpg">Black</color_swatch>
</size>
<size description="Extra Large">
<color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
<color_swatch image="black_cardigan.jpg">Black</color_swatch>
</size>
</catalog_item>
</product>
</catalog>
<catalog_item>
のいくつかの
<size>
の要素をできるようにしたいと仮定すると、
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="catalog">
<xs:complexType>
<xs:sequence>
<xs:element name="product">
<xs:complexType>
<xs:sequence>
<xs:element name="catalog_item">
<xs:complexType>
<xs:sequence>
<xs:element name="item_number">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="price" type="xs:decimal"/>
<xs:element name="size">
<xs:complexType>
<xs:all minOccurs="1">
<xs:sequence>
<xs:element name="color_swatch" type="xs:string">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
</xs:sequence>
\t \t \t \t <xs:attribute name="image" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
\t \t \t <xs:attribute name="description" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
\t \t </xs:sequence>
\t \t <xs:attribute name="gender" type="xs:string"/>
\t \t </xs:complexType>
</xs:element>
\t </xs:sequence>
\t <attribute name="description" type="xs:string"/>
<attribute name="product_image" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
現在の問題を解決する:あなたは、最後の2つの属性の宣言の「
xs:
」プレフィックスを忘れてしまいました。しかし、今、私はエラーが発生しました "無効なコンテンツは、 'catalog_item'要素で始まる要素で始まっていないと言っています。この時点で子要素はありません。 '15'列、 '38'列" このエラーはxmlファイル。なぜなら、私のxsdファイルで定義されている 'color_swatch'要素は、xmlに複数の要素を持たせることができないからですか? –おそらく 'maxOccurs =" unbounded "を' 'に設定する必要があります。 –
potame