Subject: Re: [xsl] node-set processing From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 04 Dec 2005 21:00:25 -0500 |
For example, does a nodeset keep the position of the original source
or will position give me the position in the node set?
Can you even run position on a node-set?
T:\ftemp>type kamal.xml <Table> <Row> <Cell>Cell 1</Cell> <Cell>Cell 2</Cell> </Row> <Row> <Cell>This is the longest cell</Cell> <Cell>Cell 3</Cell> </Row> </Table>
T:\ftemp>type kamal.xsl <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/Table"> <xsl:call-template name="find-longest"> <xsl:with-param name="set" select=".//Cell"/> </xsl:call-template> </xsl:template>
<xsl:template name="find-longest"> <xsl:param name="set"/> <xsl:param name="index" select="1"/> <xsl:param name="longest" select="0"/> <xsl:choose> <xsl:when test="$index > count($set)"> <!--finished looking--> <xsl:value-of select="$longest"/> </xsl:when> <xsl:when test="string-length($set[$index])>$longest"> <!--found new longest--> <xsl:call-template name="find-longest"> <xsl:with-param name="set" select="$set"/> <xsl:with-param name="index" select="$index + 1"/> <xsl:with-param name="longest" select="string-length($set[$index])"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <!--this isn't any longer--> <xsl:call-template name="find-longest"> <xsl:with-param name="set" select="$set"/> <xsl:with-param name="index" select="$index + 1"/> <xsl:with-param name="longest" select="$longest"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template>
</xsl:stylesheet> T:\ftemp>xslt kamal.xml kamal.xsl con 24 T:\ftemp>
-- Upcoming XSLT/XSL-FO hands-on courses: Denver,CO March 13-17,2006 World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] node-set processing, Kamal Bhatt | Thread | Re: [xsl] node-set processing, Kamal Bhatt |
Re: [xsl] R: [xsl] IQuestion about , G. Ken Holman | Date | [xsl] Formatting table information, Kamal Bhatt |
Month |