簡體   English   中英

XSD元素類型不會以匹配的結束標簽終止

[英]XSD element type won't terminate with matching end-tag

我收到有關XSD代碼的錯誤消息-“元素類型“元素”必須由匹配的結束標記/ element終止”。這顯示在/ all行上。這僅發生在一種元素類型上,不是我不理解的其他人

 <?xml version = "1.0"?> <schema xmlns:xsd = "http://wwww.w3.org/2001/XMLSCHEMA" xmlns:nutrition = "http://wwww.grandmascookies.com/nutrition" targetNamespace = "http://www.grandmascookies.com/nutrition"> <simpleType name = "amount"> <restriction base = "int"/> </simpleType> <simpleType name = "unit"> <restriction base = "string"/> </simpleType> <complexType name = "nutritionFact"> <all> <element name = "amount" type = "nutrition:amount"/> <element name = "unit" type = "nutrition:unit"/> </all> </complexType> <complexType name = "productType"> <all> <element name = "product" type = "string"> <element name = "servingsize" type = "nutrition:nutritionFact"/> <element name = "calories" type = "nutrition:nutritionFact"/> <element name = "caloriesFat" type = "nutrition:nutritionFact"/> <element name = "gramsFat" type = "nutrition:nutritionFact"/> <element name = "saturatedFat" type = "nutrition:nutritionFact"/> <element name = "mgCholestral" type = "nutrition:nutritionFact"/> <element name = "mgSodium" type = "nutrition:nutritionFact"/> <element name = "totalCarbs" type = "nutrition:nutritionFact"/> <element name = "fiber" type = "nutrition:nutritionFact"/> <element name = "sugar" type = "nutrition:nutritionFact"/> <element name = "protein" type = "nutrition:nutritionFact"/> </all> </complexType> <xsd:complexType name = "productType1"> <xsd:all> <xsd:element name = "item" type = "nutrition:productType"/> <xsd:element name = "items" type = "nutrition:productType1"/> </xsd:all> </xsd:complexType> </schema> 

更改

<element name = "product" type = "string"> 

<element name = "product" type = "string"/>
                                         ^

消除錯誤。

all關閉時報告錯誤的原因是,直到那一刻,仍可能關閉未關閉的element ,以便XML的格式正確。 但是,一旦all都解決了,那么顯然就不可能形成良好的形式。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM