 |
 |
 |
Hi Michael and Wendell, here's the code I submitted originally. If
I want to upgrade the xsl code below to xslt 2.0, what changes are
required, apart from the version number in the second line? And where do I
insert the part that Michael suggested below?
<xsl:variable name="keywords" as="xs:string*">
<w>word1</w>
<w>word2</w>
<w>word3</w>
</xsl:variable>
<xsl:function name="f:matches-keyword" as="xs:boolean">
<xsl:param name="in" as="xs:string"/>
<xsl:sequence select="some $w in $keywords satisfies contains($in, $w)"/>
</xsl:function>
<xsl:template match="item[f:matches-keyword(description)]">
.. process the item ..
</xsl:template>
<xsl:template match="item">
.. do nothing ..
</xsl:template>
<?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" encoding="ISO-8859-1" />
<xsl:template match="*">
<xsl:for-each select="//item">
<xsl:if test="contains(description, 'word1')
or contains(description, 'word2')
or contains(description, 'word3')
or contains(description, 'word4')
or contains(description, 'word5') <--- plus 20 or more other words -->
<xsl:if test="position()<10">
<p>
<strong><xsl:value-of select="title" /></strong>
<xsl:text disable-output-escaping="yes"><br /></xsl:text>
<em>
<xsl:variable name="convertdate" select="pubDate" />
<xsl:variable name="pubday" select="substring($convertdate, 6,2)" />
<xsl:value-of select="$pubday" />
<xsl:text>/</xsl:text>
<xsl:variable name="pubmonth" select="substring($convertdate, 9,3)" />
<xsl:choose>
<xsl:when test="$pubmonth='Jan'">01</xsl:when>
<xsl:when test="$pubmonth='Feb'">02</xsl:when>
<xsl:when test="$pubmonth='Mar'">03</xsl:when>
<xsl:when test="$pubmonth='Apr'">04</xsl:when>
<xsl:when test="$pubmonth='May'">05</xsl:when>
<xsl:when test="$pubmonth='Jun'">06</xsl:when>
<xsl:when test="$pubmonth='Jul'">07</xsl:when>
<xsl:when test="$pubmonth='Aug'">08</xsl:when>
<xsl:when test="$pubmonth='Sep'">09</xsl:when>
<xsl:when test="$pubmonth='Oct'">10</xsl:when>
<xsl:when test="$pubmonth='Nov'">11</xsl:when>
<xsl:when test="$pubmonth='Dec'">12</xsl:when>
</xsl:choose>
<xsl:variable name="pubyear" select="substring($convertdate, 13,4)" />
<xsl:text>/</xsl:text>
<xsl:value-of select="$pubyear" />
</em>
<xsl:text disable-output-escaping="yes"><br /></xsl:text>
<xsl:value-of select="description" disable-output-escaping="yes" />
<xsl:text> .. </xsl:text>
<a>
<xsl:attribute name="href">
<xsl:value-of select="link" />
</xsl:attribute>
<xsl:attribute name="title">full story</xsl:attribute>
<xsl:text>full story</xsl:text>
</a>
</p>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
--
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 9 at http://www.opera.com
Powered by Outblaze
|
 | 

|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |