2
私は、次のXML検証するスキーマの書き込みをしようとしている:(。ommitedタグと終了タグを見出しその他の項目の要素、黒字)XMLスキーマ
<category type="rifles">
<item>
<name>
AK47
</name>
<description>
The USSR's chief export back in the day, and the guerrilla's best friend. On African flags than any other symbol.
</description>
<cost>
4000
</cost>
<image>
ak47.jpg
</image>
<provenance>
The USSR.
</provenance>
<quantity>
10000
</quantity>
</item>
を
そして、次のスキーマ開発しました:http://www.xmlme.com/Validator.aspx?mid=83で
<element name="store">
<complexType>
<sequence>
<element name="category" maxOccurs="unbounded" >
<complexType>
<simpleContent>
<extension base="string">
<attribute name="type" type="string" />
</extension>
</simpleContent>
<sequence>
<element name="item" maxOccurs="unbounded" >
<complexType>
<sequence>
<element name="name" type="string"/>
<element name="description" type="string"/>
<element name="image" type="string"/>
<element name="cost" type="number"/>
<element name="provenence" type="string"/>
<element name="quantity" type="number"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
バリデータを使用して、私が取得:
スキーマエラー:System.Xml.Schema.XmlSchemaException:複合型のコンテンツモデルは、 '注釈'(存在する場合)で構成されている必要があります。 'simpleContent'、 'complexContent'、 'group'、 'choice'、 'sequence'、 'all'のいずれか1つが続きます。 0個以上の '属性'または '属性グループ'が続きます。 0または1つの 'anyAttribute'が続きます。
私はこれが愚かに聞こえるかもしれないことは知っていますが、誰かが私のエラーを指摘できますか?
おかげでコリンをお試しください!私は属性がシーケンスの後に宣言されなければならないと推測しています... –
XSDのルールはすべてちょっと気味悪いですが、エディタを使う方がいいです(液体のXMLスタジオに行く!) – Colin
XMLは、コンテンツの前に属性とXMLスキーマが属性定義* after *コンテンツを持つようにすることができます。これは、コンテンツにネストされた要素がある場合、属性定義はその要素から* long * – 13ren