|
If our schema implies the usage of the same element in several
places we have to declare it multiple times. In order to avoid this
we can define such a shared element at the end of schema scope one time.
After that, when it is necessary to insert this element declaration we
use ref attribute instead of name, like follows:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="purchase-order">
<xs:complexType>
<xs:sequence>
...
<xs:element name="order-items">
<xs:complexType>
<xs:sequence>
////////////// here we refer an element declared somewhere late:
<xs:element ref="item" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
...
</xs:sequence>
...
</xs:complexType>
</xs:element>
////////////// we declare all shared elements outside the root one:
<xs:element name="item">
<xs:complexType>
...
</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.