|
Subject: Re: to extract the longest string (fwd) From: "C.V. Radhakrishnan" <cvr@xxxxxxxxxxxxxxx> Date: Fri, 18 Aug 2000 13:43:16 +0530 (IST) |
I tested the following code in SAXON and I could not get the
expected longest string, which is "cxxyycc".
Please check
Thanks
<?xml version="1.0"?>
<table>
<row>
<col align="l"/>
<col align="l"/>
<col align="l"/>
</row>
<row>
<col align="cxxyy"/>
<col align="c"/>
<col align="c"/>
</row>
<row>
<col align="cxx"/>
<col align="c"/>
<col align="c"/>
</row>
<row>
<col align="cx"/>
<col align="c"/>
<col align="c"/>
</row>
</table>
**********************************************************************
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
<xsl:template match="table">
<xsl:variable name="longest">
<xsl:apply-templates select="row[1]" mode="get-longest" />
</xsl:variable>
</xsl:template>
<xsl:template match="row" mode="get-longest">
<xsl:variable name="current">
<xsl:for-each select="col">
<xsl:value-of select="@align" />
</xsl:for-each>
</xsl:variable>
<xsl:variable name="longest">
<xsl:apply-templates select="following-sibling::row[1]"
mode="get-longest" />
</xsl:variable>
<xsl:choose>
<xsl:when test="string-length($longest) > string-length($current)">
<xsl:value-of select="$longest"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$current" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Rajagopal
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| to extract the longest string (fwd), C.V. Radhakrishnan | Thread | Re: to extract the longest string (, Jeni Tennison |
| Re: Merging and Quines, Tom Mullen | Date | Re: Retriving next 10 elements?, Jeni Tennison |
| Month |