In: Computer Science
Internet Programming
Project #4: XML, Schema and XSLT
1. Write a complete XML file named textbooks.xml, in which you describe at least a partial list of the textbooks you are using this semester. You should include at least two distinct textbooks. If you are using only one text this semester, expand your list to cover the current academic year.
Your description of each book must include the title, author(s), publisher, year of publication, and the ISBN. For each author, specify the first and last name as distinct values. Include both a name and website for the publisher. Optionally, try also to include any book-specific website (especially if it is distinct from the main publisher site, and if its URL is not ridiculously long). Finally, specify the edition and cover type (paperback or hardcover) of each book you are using. Make sure your final XML document is well-formed.
2. Write an XML Schema that can be used to validate textbooks.xml and name it textbook.xsd . Finally, remember to modify your new XML document so that it references your schema.
3. Develop an XSL Stylesheet for easy viewing of your textbook list and name it textbook.xsl
PLEASE RATE MY ANSWER I SUFFERING FROM SCORE ANY DOUBTS ASK ME
Textbooks.xml :
<?xml version="1.0" encoding="utf-8"?>
<textbooks>
<textbook>
<title>Introduction to
Algorithms</title>
<authors>
<author>
<firstName>Thomas
H.</firstName>
<lastName>Cormen</lastName>
</author>
<author>
<firstName>Charles
E.</firstName>
<lastName>Leiserson</lastName>
</author>
</authors>
<publisher>
<name>PHI Learning Pvt. Ltd.
(Originally MIT Press)</name>
<website>www.mitpress.com</website>
</publisher>
<Year-of-Publication>2010</Year-of-Publication>
<ISBN>8120340078</ISBN>
<book-specific-website></book-specific-website>
<edition>3</edition>
<cover-type>Paperback</cover-type>
</textbook>
<textbook>
<title>Operating System
Concepts</title>
<authors>
<author>
<firstName>Abraham</firstName>
<lastName>Silberschatz</lastName>
</author>
</authors>
<publisher>
<name>Wiley
India</name>
<website>www.wileyindia.com</website>
</publisher>
<Year-of-Publication>2005</Year-of-Publication>
<ISBN>8126554274</ISBN>
<book-specific-website>fgdfg</book-specific-website>
<edition>9</edition>
<cover-type>Hardcover</cover-type>
</textbook>
</textbooks>
-----------------------------------------------------------------------------------------------------------------------------------------------------------
textbook.xsd :
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="textbooks">
<xs:complexType>
<xs:sequence>
<xs:element
maxOccurs="unbounded" name="textbook">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string" />
<xs:element name="authors">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="author">
<xs:complexType>
<xs:sequence>
<xs:element name="firstName" type="xs:string" />
<xs:element name="lastName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="publisher">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="website" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Year-of-Publication" type="xs:unsignedShort"
/>
<xs:element name="ISBN" type="xs:unsignedLong" />
<xs:element name="book-specific-website" type="xs:string"
/>
<xs:element name="edition" type="xs:unsignedByte" />
<xs:element name="cover-type" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-----------------------------------------------------------------------------------------------------
textbook.xsl :
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th
style="text-align:left">Title</th>
<th
style="text-align:left">Author First name</th>
<th style="text-align:left">Author Last name</th>
<th style="text-align:left">Publisher name</th>
<th style="text-align:left">Publisher
website</th>
<th style="text-align:left">Year of
Publication</th>
<th style="text-align:left">ISBN</th>
<th style="text-align:left">book website</th>
<th style="text-align:left">edition</th>
<th style="text-align:left">cover type</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of
select="catalog/cd/title"/></td>
<td><xsl:value-of
select="catalog/cd/authors/firstName"/></td>
<td><xsl:value-of
select="catalog/cd/authors/lastName"/></td>
<td><xsl:value-of
select="catalog/cd/publisher/name"/></td>
<td><xsl:value-of
select="catalog/cd/publisher/website"/></td>
<td><xsl:value-of
select="catalog/cd/Year-of-Publication"/></td>
<td><xsl:value-of
select="catalog/cd/ISBN"/></td>
<td><xsl:value-of
select="catalog/cd/book-specific-website"/></td>
<td><xsl:value-of
select="catalog/cd/edition"/></td>
<td><xsl:value-of
select="catalog/cd/cover-type"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>