Hi
@BeBor1426Thank you for the posting here,
Here is your problem's solution!!
In your HTML file, you're using <link> to reference the XSLT stylesheet. This is incorrect. Instead, you should use the <?xml-stylesheet?> processing instruction to link the XSLT file. Here's the corrected HTML code:
<!DOCTYPE html>
<html>
<head>
<title>My Catalog</title>
<link rel="stylesheet" href="styles.css">
<?xml-stylesheet type="text/xsl" href="myindex.xsl"?>
</head>
<body>
<h1>HTML Heading</h1>
<p>HTML paragraph.</p>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
</body>
</html>
In your XSLT file, there's a typo in the opening <?XSL/Transforml ... ?> tag. It should be <?xml-stylesheet ... ?> instead. Also, there's a small issue with your XPath expressions in the <xsl:for-each> loop. It should be <xsl:value-of select="title"/> and <xsl:value-of select="artist"/>. Here's the corrected XSLT code:
<?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 CDs</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Title</th>
<th style="text-align:left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Make sure that both index.html and myindex.xsl are in the same directory, and then try opening index.html in your web browser again. It should now apply the XSLT transformation correctly.
Best Regards,
AddWebSolution