HTML and CSS Reference
Defining the Parent Element
The next part of the schema defines the parent element, <products>. This element
is a complex type because it contains a child element, <item>. The attributes of minOccurs
and maxOccurs indicate the cardinality. Cardinality is the number of relationships between
a parent and child element. The minOccurs attribute indicates that at least one item must
exist, and the maxOccurs attribute of unbounded indicates there can be an infinite number
To Enter Code for the <products> Element
Table 12-12 shows the code for inserting the parent element.
Table 12-12 Code for Inserting the <products> Element
<xs:element name=”item” type=”childType” minOccurs=”1”
Line 11 is an <element> tag that defines the products element in the XML document. Line 12 indicates this is a
complex data type element with children. The <sequence> tag at line 13 indicates the following elements must appear
in sequence. Only one element is identified in line 14, and that is item with the minOccurs and maxOccurs attributes,
used to define cardinality. Lines 15, 16, and 17 close the element tags in 13, 12, and 11, in order.
The following step enters the code for the parent element.
press the e n t e r key
once to place the
insertion point on a
blank line 11.
Click line 10 and
code shown in
Table 12-12 to
add the <products>
Enter the XML
element with child
e n t e r key
twice after line 17
press e n t e r