|
Definitions of complex elements and types |
|
|
In additions to primitives, XML schema of course allows to define
complex types, like structures. There are two kinds of complex types:
a sequence and a choice. While sequence represents a set of child
elements present at the same time, choice can contain only one of them.
We use in our definition sequence-type to define the content of
purchase order:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="purchase-order">
////////////// our purchase-order is a complex of type sequence:
<xs:complexType>
<xs:sequence>
////////////// order originator is alseo described as sequence of one element:
<xs:element name="purchased-by">
<xs:complexType>
<xs:sequence>
<xs:element name="address" type="xs:string"/>
</xs:sequence>
...
</xs:complexType>
</xs:element>
////////////// the items represents a collection:
<xs:element name="order-items">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
...
<xs:attribute name="code" type="xs:integer"/>
...
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
...
</xs:complexType>
</xs:element>
</xs:schema>
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.