|
Posted by Andy Dingley on 11/27/51 11:57
Jared Zimmerman wrote:
> Thanks, i don't mind learning, i was just hoping that it was a little
> more simple, oh well
Try this as a crude XSLT starter
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="html"
omit-xml-declaration = "yes"
standalone = "yes"
doctype-public = "-//W3C//DTD HTML 4.01 Strict//EN"
doctype-system = "http://www.w3.org/TR/html4/strict.dtd"
cdata-section-elements = "script"
indent = "yes"
media-type = "text/html" />
<xsl:template name="embedded-br-to-text" >
<xsl:param name="input" select="/.." />
<xsl:variable name="cdr" select="substring-after ($input,
'<br>')" />
<xsl:choose>
<xsl:when test="$cdr" >
<xsl:value-of select="substring-before ($input, '<br>')"
/>
<xsl:text>
</xsl:text>
<xsl:call-template name="embedded-br-to-text" >
<xsl:with-param name="input" ><xsl:value-of select="$cdr"
/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$input" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="one-item" >
<xsl:param name="rss-item" select="/.." />
<pre><xsl:value-of select="title" />
<xsl:text> </xsl:text>
<xsl:value-of select="pubDate" />
<xsl:text>
</xsl:text>
<xsl:call-template name="embedded-br-to-text" >
<xsl:with-param name="input" ><xsl:value-of
select="substring-after(substring-after(string(description),
'</a>'), '</a>')" /></xsl:with-param>
</xsl:call-template></pre>
</xsl:template>
<xsl:template match="/">
<html><title>Dodgeball</title><body>
<xsl:for-each select="//item" >
<xsl:sort select="pubDate" />
<xsl:if test="position() = 1" >
<xsl:call-template name="one-item" >
<xsl:with-param name="rss-item" select="." />
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</body></html>
</xsl:template>
</xsl:stylesheet>
Navigation:
[Reply to this message]
|