[英]XML schema issue: Repeating Element not repeating
I have a pretty standard xml schema defining an element called "part" that should repeat. 我有一个漂亮的标准xml模式,该模式定义了一个应该重复的名为“ part”的元素。
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="part">
<xs:complexType>
<xs:sequence>
<xs:element name="part_number" type="xs:string"/>
<xs:element name="price" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
problem is, when I use this schema to export a price list I get this: 问题是,当我使用此架构导出价格表时,得到以下信息:
<?XML version="1.0" encoding="UTF-8" standalone="yes"?>
<part>
<part_number>10-000</part_number>
<price>151.8</price>
</part>
When I want mulitple <part>
elements. 当我想要多个<part>
元素时。 Where am I messing up in the schema? 我在架构中哪里搞砸了?
<xs:element name="parts">
<xs:complexType>
<xs:sequence>
<xs:element name="part" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="part_number" type="xs:string"/>
<xs:element name="price" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
http://www.w3schools.com/schema/schema_example.asp http://www.w3schools.com/schema/schema_example.asp
您的元素需要maxOccurs =“ unbounded”,因为maxOccurs的默认值为1。
<xs:element name="part" maxOccurs="unbounded">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.