Write an XML file that displays book information with the following fields: Title of the book, Author Name, ISBN number, Publisher name, Edition, and Price. Define an XML schema to validate the XML document created above.
Sat Nov 02 2024 16:50:04 GMT+0000 (Coordinated Universal Time)
Saved by
@cpbab
books.xml
<?xml version="1.0" encoding="UTF-8"?>
<bookstore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="books.xsd">
<book>
<title>Introduction to XML</title>
<author>John Doe</author>
<isbn>978-0-123456-47-2</isbn>
<publisher>Example Press</publisher>
<edition>3rd</edition>
<price>39.99</price>
</book>
<book>
<title>Advanced XML Concepts</title>
<author>Jane Smith</author>
<isbn>978-0-765432-10-5</isbn>
<publisher>Tech Books Publishing</publisher>
<edition>1st</edition>
<price>45.00</price>
</book>
</bookstore>
books.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="bookstore">
<xs:complexType>
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="isbn" type="xs:string"/>
<xs:element name="publisher" type="xs:string"/>
<xs:element name="edition" type="xs:string"/>
<xs:element name="price" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
content_copyCOPY
Comments