no use for-each
xml is not a programming language
to select you must use the namespace
then exclude the namespace for the html code
for css use style tag
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://xml.netbeans.org/schema/BookShelf" xmlns:ns1="http://xml.netbeans.org/schema/Book_Author"
exclude-result-prefixes="ns0 ns1">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html xslns="http://xml.netbeans.org/schema/BookShelf">
<style type="text/css">
table{
border :1px black solid;
}
td,th{
border :1px black solid;
}
th{
background-color:#9acd32;
}
</style>
<body>
<xsl:apply-templates select="ns0:My_BookShelf"/>
</body>
</html>
</xsl:template>
<xsl:template match="ns0:My_BookShelf">
<table>
<tr>
<th>ISBN No</th>
<th>Book Title</th>
<th>Publisher</th>
<th>Edition</th>
<th>Language</th>
<th>Number of Pages</th>
<th>Category</th>
<th>Rating</th>
<th>Additional Material</th>
<th>Cover Type</th>
<th>Price</th>
<th>Ownership</th>
<th>Description</th>
<th>Author</th>
</tr>
<xsl:apply-templates select="ns0:Book_Extension"/>
</table>
</xsl:template>
<xsl:template match="ns0:Book_Extension">
<tr>
<td>
<xsl:value-of select="@ISBN_No"/>
</td>
<td>
<xsl:value-of select="ns0:Book_Title"/>
</td>
<td>
<xsl:value-of select="ns0:Publisher"/>
</td>
<td>
<xsl:value-of select="ns0:Edition"/>
</td>
<td>
<xsl:value-of select="ns0:Language"/>
</td>
<td>
<xsl:value-of select="ns0:Number_Of_Pages"/>
</td>
<td>
<xsl:value-of select="ns0:Category"/>
</td>
<td>
<xsl:value-of select="ns0:Rating"/>
</td>
<td>
<xsl:value-of select="ns0:Additional_Material"/>
</td>
<td>
<xsl:value-of select="ns0:Cover_Type"/>
</td>
<td>
<xsl:value-of select="ns0:Price"/>
</td>
<td>
<xsl:value-of select="ns0:Ownership"/>
</td>
<td>
<xsl:value-of select="ns0:Description"/>
</td>
<td><xsl:value-of select="ns0:Author/ns1:Author"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
result
Code:
<html xslns="http://xml.netbeans.org/schema/BookShelf">
<style type="text/css">
table{
border :1px black solid;
}
td,th{
border :1px black solid;
}
th{
background-color:#9acd32;
}
</style>
<body>
<table>
<tr>
<th>ISBN No</th>
<th>Book Title</th>
<th>Publisher</th>
<th>Edition</th>
<th>Language</th>
<th>Number of Pages</th>
<th>Category</th>
<th>Rating</th>
<th>Additional Material</th>
<th>Cover Type</th>
<th>Price</th>
<th>Ownership</th>
<th>Description</th>
<th>Author</th>
</tr>
<tr>
<td>1-55860-819-2</td>
<td>Information Visualization Perception for Design</td>
<td>Morgan Kaufmann</td>
<td>Edition 2, 2004</td>
<td>English</td>
<td>488</td>
<td>Scientific Book</td>
<td>4 Stars</td>
<td>Nothing</td>
<td>Soft Cover</td>
<td>40.0</td>
<td>Mine</td>
<td>Good</td>
<td>Colin Ware</td>
</tr>
</table>
</body>
</html>
for learning i show the namespace ns1 by author
Bookmarks