Subject: RE: [xsl] Another beginner question about position() counting usi ng recursi ve templates From: "Braumüller, Hans" <h.braumueller@xxxxxxxxxxxx> Date: Tue, 9 Apr 2002 13:28:38 +0200 |
Hi Greg, thank you for spending time to solve my problem! It´s works! Hans Braumüller > -----Ursprüngliche Nachricht----- > Von: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]Im Auftrag von > Greg Faron > Gesendet: Montag, 8. April 2002 18:05 > An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sorting by an attribute, Vrajitoru | Thread | [xsl] Floating point numbers in XPa, Richard Jinks |
Re: [xsl] Removing namespaces from , Jeni Tennison | Date | Re: [xsl] building namespaces, Andrew Welch |
Month |