<?xml version="1.0" encoding="utf-8"?>
<!-- generate a table (not the whole html) from rss -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<!--
<xsl:template match="/">
<xsl:apply-templates select="//channel" />
</xsl:template>
-->
<xsl:template match="/">
<xsl:apply-templates select="//channel" />
</xsl:template>
<xsl:template match="channel">
<table border="1">
<xsl:apply-templates select="//channel/item" />
</table>
</xsl:template>
<xsl:template match="item">
<tr>
<td width="20%"><a href="{link}"><xsl:value-of select="title"/></a></td>
<td width="50%"><xsl:value-of select="pubDate"/></td>
<td width="30%"><a href="mailto:{author}"><xsl:value-of select="author"/></a></td>
</tr>
<tr>
<td colspan="3">
<xsl:apply-templates select="description"/>
<!-- <xsl:value-of select="description"/> -->
</td>
</tr>
</xsl:template>
<!-- below substitution code is copied from
http://www.dpawson.co.uk/xsl/sect2/break.html -->
<xsl:template match="description">
<xsl:call-template name="substitute">
<xsl:with-param name="string" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template name="substitute">
<xsl:param name="string" />
<xsl:param name="from" select="'
'" />
<xsl:param name="to">
<br />
</xsl:param>
<xsl:choose>
<xsl:when test="contains($string, $from)">
<xsl:value-of select="substring-before($string, $from)" />
<xsl:copy-of select="$to" />
<xsl:call-template name="substitute">
<xsl:with-param name="string"
select="substring-after($string, $from)" />
<xsl:with-param name="from" select="$from" />
<xsl:with-param name="to" select="$to" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
# |
Change |
User |
Description |
Committed |
|
#2
|
3361 |
Jay Han |
stuff description as CDATA and use XSLT substitution to turn \n to <br/> |
|
|
#1
|
3359 |
Jay Han |
generate html table (only the table) from rss |
|
|