|
Definitions of attributes |
|
|
The attributes in schema are defined like child elements. In order to
have the attributes the element has a complex type. The only difference
is that attributes are not included into sequence/choice scope; rather
they are located in complexType-section immediately.
The element may contain any number of attribute-definitions:
<?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:element name="item" maxOccurs="unbounded">
<xs:complexType>
////////////// attributes must be locates in complexType definition:
<xs:attribute name="code" type="xs:integer"/>
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="CD"/>
<xs:enumeration value="DVD"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="label" type="xs:string"/>
</xs:complexType>
</xs:element>
...
</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.