[英]XML Schema Validation for unknown elements
我正在尝试使用C#中的架构来验证XML。 我将在row元素下拥有一个未知元素。 我正在使用xs:any
,出现以下错误
元素“行”具有无效的子元素“名称”。
模式-
<xs:element name="table">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="row">
<xs:complexType>
<xs:sequence>
<xs:any processContents="lax"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
XML-
<table>
<row>
<ProductID>994</ProductID>
<Name>LL Bottom Bracket</Name>
<ProductModel>LL Bottom Bracket</ProductModel>
<CultureID>en </CultureID>
<Description>Chromoly steel.</Description>
</row>
</table>
您尚未在xs:any
上指定maxOccurs
, 并且maxOccurs
默认值为1 ,这意味着不允许第二个元素Name
,因此错误消息为:
元素“行”具有无效的子元素“名称”。
通过将maxOccurs="unbounded"
添加到xs:any
来进行更正:
<xs:any processContents="lax" macOccurs="unbounded"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.