Hi there!
I'm learning XSLT, and as an exercise, I'm trying to get the top links of http://ptchan.org/fa/, namely {al, az, fa, ga, li, tm}. To do so, I've created the following XSL Template:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<body>
<h2>Links</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>URL</th>
</tr>
<xsl:for-each select="//div[@class='navbar']/a">
<tr>
<td><xsl:value-of select="self::node()"/></td>
<td><xsl:value-of select="@href"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I've also created a dummy XML file representing just the nodes I want to get in the regular file, which was generated via curl http://ptchan.org/fa/ | tidy -utf8 -asxml
. Transforming, with xsltproc
, works with the dummy file but not with the regular one. After some googling, I've found that the (1) DOCTYPE, and (2)
on the source file are causing trouble, but even after removing them, the transformation doesn't occur.
Any idea on what I'm doing wrong and on how to transform that file?
Thanks!