I'm supposed to create a XML Schema for this.
Where column A is Tag Name column B is Data Type column C is Max length and column D is Mandatory
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:complexType name="Applicant">
<xsd:sequence>
<xsd:element name="Surname" >
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="26" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="FirstName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="26" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
//etc..
</xsd:schema>
And this is what I've tried yet.
But my problem is I'm not able to give Mandatory
for complex type Applicant
and element names
(Surname,First name) because required
is not available for elements. But it is available for attributes.
Plz Feel free to edit and comment for any clarifications
Thank You.
The default value of minOccurs
and maxOccurs
of a element is 1
.
So, by default, each element has to appear, if you don't define those parameters.
I'm not shure, but i have tested with success this xsd
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="rootelement">
<xsd:complexType>
<xsd:all>
<xsd:element name="optional_element" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="26"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="required_element" minOccurs="1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="26"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="optional_complex_type" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ct_1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="26"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="required_complex_type" minOccurs="1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ct_1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="26"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.