A repeating node means that more than one instance of this node can be specified. For example, in the following XML data there are three instances of the priceRequest node, as shown in the following listing:
<?xml version="1.0"?>
<priceQuote xmlns="http://www.example.org/price">
<customerName>Acme Inc</customerName>
<shipAddress street="12 Springs Rd" city="Morris Plains" state="nj" zip="07960"/>
<priceRequests>
<priceRequest>
<widgetId>12</widgetId>
<price>1.00</price>
</priceRequest>
<priceRequest>
<widgetId>134</widgetId>
<price>34.10</price>
</priceRequest>
<priceRequest>
<widgetId>211</widgetId>
<price>10.00</price>
</priceRequest>
</priceRequests>
</priceQuote>
A segment of the XML Schema for the preceding XML data is shown in the following listing:
<?xml version="1.0"?>
<xsd:schema . . . >
. . .
<xsd:element name="widgetId" type="xsd:integer"/>
<xsd:element name="price" type="xsd:float"/>
<xsd:element name="priceRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="pri:widgetId"/>
<xsd:element ref="pri:price"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="priceRequests">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="pri:priceRequest" minOccurs="1" maxOccurs="10"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
. . .
<xsd:element name="priceQuote">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="pri:customerName" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="pri:shipAddress" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="pri:priceRequests"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
The minOccurs="1" and maxOccurs="10" settings, in the definition of the priceRequest element (highlighted in bold in the preceding listing), specify that there can be one to ten instances of the priceRequest element. This defines priceQuote as a repeating element.
To View the Full listing of the XML Schema, Open the PriceQuote.xsd file
The PriceQuote.xsd file is displayed.
![]() |
|