Subject: RE: [xsl] RE: xsl for From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Fri, 7 Apr 2006 16:24:46 +0100 |
> <pageBrowser startPage="5" pageSize="10"/> > > And I want this output : > > <a href="toto.htm?skip=50">5</a> > <a href="toto.htm?skip=60">6</a> > <a href="toto.htm?skip=70">7</a> > <a href="toto.htm?skip=80">8</a> > <a href="toto.htm?skip=90">9</a> > <a href="toto.htm?skip=100">10</a> > <a href="toto.htm?skip=110">11</a> > <a href="toto.htm?skip=120">12</a> > <a href="toto.htm?skip=130">13</a> > <a href="toto.htm?skip=140">14</a> Not sure here whether 10 is the number of <a> elements to generate or the multiplier. I'll use it for both... In XSLT 2.0, it's easy (as things often are!) <xsl:for-each select="@startPage to (@startPage + @pageSize - 1)"> <a href="tot.htm?skip={10*.}"><xsl:value-of select="."/></a> </xsl:for-each> (You might have to cast the attribute values to xs:integer if your source document doesn't have a schema) In 1.0 you use the Piez trick of iterating over a sufficiently large but otherwise arbitrary node-set: <xsl:for-each select="//node()[position() <= $pageSize]"> <a href="tot.htm?skip={10*(position()-1+$startPage}"><xsl:value-of select="position()-1+$startPage"/></a> </xsl:for-each> having first initialized the two variables. Michael Kay http://www.saxonica.com/ > > I mean I want to use a loop somewhere and I don't want to have > > <xsl:template match="pageBrower"> > <a href="toto.htm?skip={@startPage*@pageSize}"><xsl:value-of > select="@startPage"/></a> > <a href="toto.htm?skip={(@startPage+1)*@pageSize}"><xsl:value-of > select="@startPage+1"/></a> > <a href="toto.htm?skip={(@startPage+2)*@pageSize}"><xsl:value-of > select="@startPage+2"/></a> > <a href="toto.htm?skip={(@startPage+3)*@pageSize}"><xsl:value-of > select="@startPage+3"/></a> > ... > </xsl:template> > > Thanks in advance > > Philippe
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE: xsl for, Philippe LAPLANCHE | Thread | RE: [xsl] RE: xsl for, cknell |
[xsl] RE: xsl for, Philippe LAPLANCHE | Date | RE: [xsl] RE: xsl for, cknell |
Month |