This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Another beginner question about position() counting using recursi ve templates
- From: =?utf-8?B?IkJyYXVtw7xsbGVyLCBIYW5zIg==?= <h dot braumueller at hanseorga dot de>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 9 Apr 2002 13:28:38 +0200
- Subject: RE: [xsl] Another beginner question about position() counting using recursi ve templates
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Greg,
thank you for spending time to solve my problem!
It´s works!
Hans Braumüller
> -----Ursprüngliche Nachricht-----
> Von: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]Im Auftrag von
> Greg Faron
> Gesendet: Montag, 8. April 2002 18:05
> An: xsl-list@lists.mulberrytech.com
> Betreff: Re: [xsl] Another beginner question about position() counting
> using recursi ve templates
>
>
> At 09:15 AM 4/8/2002, you wrote:
> >I want counting all cols from 1 to 8 and then assigning
> every number to an
> >id attrribute, idependent from their relative context node.
> >I am trying to assign a parameter and then select this <xsl:value-of
> >select="$datacells" />.
> >
> >Now i am getting 1 2 3 4
> > 1 2 3 4
> >
> >which is no wonder because that is in fact the position()
> relative to the
> >context node.
> >
> >I have no idea how to get the param datacells outputting:
> >
> > 1 2 3 4
> > 5 6 7 8
>
> Instead of position(), use the number of preceding row or
> col elements
> as your basis. Remember that you'll need to add 1 for the current
> node. Here's your stylesheet:
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/">
> <html>
> <head>
> <title>tabelle.xsl</title>
> </head>
> <body bgcolor="#cccccc" text="#000000" link="#455fbe"
> vlink="#455fbe" alink="#FF9900" topmargin="0" leftmargin="0"
> marginheight="0" marginwidth="0" id="output">
> <div align="center">
> <xsl:apply-templates select="tabelle"/>
> </div>
> </body>
> </html>
> </xsl:template>
> <xsl:template match="tabelle">
> <table cellpadding="0" cellspacing="0" border="1" align="center">
> <xsl:apply-templates select="row"/>
> </table>
> </xsl:template>
> <xsl:template match="row">
> <tr>
> <xsl:attribute name="id"><xsl:number
> value="count(preceding::row) +
> 1" format="1"/></xsl:attribute>
> <xsl:apply-templates select="col"/>
> </tr>
> </xsl:template>
> <xsl:template match="col">
> <xsl:param name="datacells" select="count(preceding::col) + 1"/>
> <td>
> <xsl:attribute name="name"><xsl:value-of
> select="@id"/></xsl:attribute>
> <xsl:attribute name="id"><xsl:value-of
> select="$datacells"/></xsl:attribute>
> <xsl:value-of select="."/>
> </td>
> </xsl:template>
> </xsl:stylesheet>
>
>
> Greg Faron
> Integre Technical Publishing Co.
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list