In: Computer Science
XML and XSL
I'm trying to style my XML code but it's not implementing the XSL file when I run it even though the file is referenced. Any help?
XML code:
<?xml version="1.0"?>
<?xml-stylesheet href="textbooks.xsl" type="text/xsl"
?>
<textbooks>
<textbook>
<title> Introduction to Design and Analysis of
Algorithms</title>
<authors>
<author>
<firstName>Anany</firstName>
<lastName>Levitin</lastName>
</author>
</authors>
<publisher>
<name>Ed, Pearson</name>
<website>https://www.pearson.com</website>
</publisher>
<Year-of-Publication>2011</Year-of-Publication>
<ISBN>978-0132316811</ISBN>
<book-specific-website></book-specific-website>
<edition>3rd edition</edition>
<cover-type>Paperback</cover-type>
</textbook>
<textbook>
<title>Software Engineering: A Practitioner’s
Approach</title>
<authors>
<author>
<firstName>Roger</firstName>
<lastName>Pressman</lastName>
</author>
</authors>
<publisher>
<name>Ed, McGraw-Hill</name>
<website>www.mheducation.com</website>
</publisher>
<Year-of-Publication>2014</Year-of-Publication>
<ISBN>8126554274</ISBN>
<book-specific-website></book-specific-website>
<edition>8th edition</edition>
<cover-type>Hardcover</cover-type>
</textbook>
<textbook>
<title>Internet and World Wide Web: How to Program with
CD-ROM BK and CD ROM</title>
<authors>
<author>
<firstName>Harvey</firstName>
<lastName>Deitel</lastName>
</author>
</authors>
<publisher>
<name>Prentice Hall,</name>
<website>https://www.amazon.com/Internet-World-Wide-Web-Program/dp/0131450913</website>
</publisher>
<Year-of-Publication>2004</Year-of-Publication>
<ISBN> 0131450913</ISBN>
<book-specific-website></book-specific-website>
<edition>3rd edition</edition>
<cover-type>Hardcover</cover-type>
</textbook>
</textbooks>
XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/textbooks">
<html>
<body>
<table border="1">
<tr>
<th>Title</th>
<th>Author First Name</th>
<th>Author Last Name</th>
<th>Publisher Name</th>
<th>Publisher website</th>
<th>Year of publication</th>
<th>ISBN</th>
<th>Book Website</th>
<th>Edition</th>
<th>Cover Type</th>
</tr>
<xsl:for-each select="textbook">
<tr>
<td><xsl:value-of
select="title"/></td>
<td><xsl:value-of
select="authors/firstName"/></td>
<td><xsl:value-of
select="authors/lastName"/></td>
<td><xsl:value-of
select="publisher/name"/></td>
<td><xsl:value-of
select="publisher/website"/></td>
<td><xsl:value-of
select="Year-of-publication"/></td>
<td><xsl:value-of
select="ISBN"/></td>
<td><xsl:value-of
select="book-specific-website"/></td>
<td><xsl:value-of
select="edition"/></td>
<td><xsl:value-of
select="cover-type"/></td>
<tr>
<xsl:for-each>
<table>
</body>
</html>
Error details :
****************************************
textbooks.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>
<table border="1">
<tr>
<th>Title</th>
<th>Author First Name</th>
<th>Author Last Name</th>
<th>Publisher Name</th>
<th>Publisher website</th>
<th>Year of publication</th>
<th>ISBN</th>
<th>Book Website</th>
<th>Edition</th>
<th>Cover Type</th>
</tr>
<xsl:for-each select="textbooks/textbook">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="authors/author/firstName"/></td>
<td><xsl:value-of select="authors/author/lastName"/></td>
<td><xsl:value-of select="publisher/name"/></td>
<td><xsl:value-of select="publisher/website"/></td>
<td><xsl:value-of select="Year-of-publication"/></td>
<td><xsl:value-of select="ISBN"/></td>
<td><xsl:value-of select="book-specific-website"/></td>
<td><xsl:value-of select="edition"/></td>
<td><xsl:value-of select="cover-type"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
***************************************************
textbooks.xml :
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="textbooks.xsl" ?>
<textbooks>
<textbook>
<title> Introduction to Design and Analysis of Algorithms</title>
<authors>
<author>
<firstName>Anany</firstName>
<lastName>Levitin</lastName>
</author>
</authors>
<publisher>
<name>Ed, Pearson</name>
<website>https://www.pearson.com</website>
</publisher>
<Year-of-Publication>2011</Year-of-Publication>
<ISBN>978-0132316811</ISBN>
<book-specific-website></book-specific-website>
<edition>3rd edition</edition>
<cover-type>Paperback</cover-type>
</textbook>
<textbook>
<title>Software Engineering: A Practitioner’s Approach</title>
<authors>
<author>
<firstName>Roger</firstName>
<lastName>Pressman</lastName>
</author>
</authors>
<publisher>
<name>Ed, McGraw-Hill</name>
<website>www.mheducation.com</website>
</publisher>
<Year-of-Publication>2014</Year-of-Publication>
<ISBN>8126554274</ISBN>
<book-specific-website></book-specific-website>
<edition>8th edition</edition>
<cover-type>Hardcover</cover-type>
</textbook>
<textbook>
<title>Internet and World Wide Web: How to Program with CD-ROM BK and CD ROM</title>
<authors>
<author>
<firstName>Harvey</firstName>
<lastName>Deitel</lastName>
</author>
</authors>
<publisher>
<name>Prentice Hall,</name>
<website>https://www.amazon.com/Internet-World-Wide-Web-Program/dp/0131450913</website>
</publisher>
<Year-of-Publication>2004</Year-of-Publication>
<ISBN> 0131450913</ISBN>
<book-specific-website></book-specific-website>
<edition>3rd edition</edition>
<cover-type>Hardcover</cover-type>
</textbook>
</textbooks>
=================================================
Output :