2013-02-23 92 views
0

我是新來的XML模式和做一個任務,我遇到了問題。我使用的教程日從w3schools.com和位於http://www.validome.org/grammar/validate/ 一個驗證下面是我的架構的開頭,這將無法驗證:xml架構驗證錯誤與minOccurs和maxOccurs屬性

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="products"> 
    <xs:complexType> 
     <xs:element name="product" minOccurs="1" maxOccurs="unbounded"> 
     <xs:complexType> 
      <xs:sequence> 
      <xs:element name="fname" type="xs:string"/> 
      <xs:element name="manufacturer" type="xs:string"/> 
      </xs:sequence> 
     </xs:complexType> 
     </xs:element> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

驗證說,有許多與5號線的問題: 1.它說不允許minOccurs和maxOccurs屬性 2.找到以元素'xs:element'開頭的無效內容。

據我所知,我遵循w3schools教程。 注意:如果刪除第3行和第4行及其相應的結束標記以及minOccurs和maxOccurs屬性,則會驗證文檔。

任何人都可以幫忙嗎? 在此先感謝

回答

2

xs:元素不能直接作爲xs的子元素出現:complexType;你需要插入一個xs:sequence元素。這是從撒克遜消息:

錯誤在XS:在第4行test.xsd的71列元素:元素 的xs:元素不能出現在這裏:預期{選擇,序列, 斷言,openContent之一,註釋,attributeGroup,anyAttribute, simpleContent,all,attribute,group,complexContent}或nothing

+0

感謝您的協助 – 2013-02-23 19:23:00