Write a program which describes XML document and corresponding Schema (use of minoccurs, maxoccurs attribute).
CODING:
.XML FILE:
<?xml version="1.0" encoding="UTF-8"?>
<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="DHTML_XML4_7.xsd">
<title>XML</title>
<author>ABC</author>
<author>XYZ</author>
<price>250</price>
</book>
.XSD FILE:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="book" type="BookType"/>
<xsd:complexType name="BookType">
<xsd:sequence>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="author" type="xsd:string" minOccurs="1" maxOccurs="2"/>
<xsd:element name="price" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
CODING:
.XML FILE:
<?xml version="1.0" encoding="UTF-8"?>
<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="DHTML_XML4_7.xsd">
<title>XML</title>
<author>ABC</author>
<author>XYZ</author>
<price>250</price>
</book>
.XSD FILE:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="book" type="BookType"/>
<xsd:complexType name="BookType">
<xsd:sequence>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="author" type="xsd:string" minOccurs="1" maxOccurs="2"/>
<xsd:element name="price" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Comments
Post a Comment