Article View: fr.comp.text.xml
Article #9015Re: XSLT: �quivalent du for ?
From: Romain Guy
Date: Fri, 22 Jun 2001 10:21
Date: Fri, 22 Jun 2001 10:21
58 lines
2870 bytes
2870 bytes
Je n'y aurais jamais pens� ! Merci 100000 fois... (esp�rons que plus
tard on aura des moyens plus simples de fiare �a :)
--
Romain "Java Swinguer !" Guy
romain.guy@jext.org
www.jext.org
"Now, don't you worry. The saucers are up there. The graveyard is out there.
But I'll be locked up safely in there."
- Paula Trent, Plan 9 From Outer Space
"Thomas Broyer" <ptittom+news@free.fr> a �crit dans le message news:
2170021.3eYUQgxmLv@ltgt.net...
> In <9gt8km$h3r$1@wanadoo.fr>, Romain Guy wrote:
>
> > Bonjour ! J'ai un document XML contenant l'attribut "lines" (par
> > exemple: lines="20"). Comment puis-je faire l'�quivalent de:
> > for(int i = 0; i < lines; i++)
> > output(i + "<br>");
> >
> > dans ma feuille de style XSL ??
>
> XSLT est un langage fonctionnel, donc utilisant, entre autres, � fond la
> r�cursivit�.
>
> function for (int cur, int max, int increment) {
> output (cur + "<br>");
> if (cur < max)
> for (cur + increment, max, increment);
> }
> puis
> for (0, lines, 1);
> (d�sol�, j'ai pas r�vis� mon LISP...)
>
> Soit
> <xsl:template name="for">
> <xsl:param name="cur" select="0"/>
> <xsl:param name="max" select="0"/>
> <xsl:param name="increment" select="1"/>
>
> <xsl:value-of select="$cur"/><br/>
> <xsl:if test="$cur < $max">
> <xsl:call-template name="for">
> <xsl:with-param name="cur" select="$cur + $increment"/>
> <xsl:with-param name="max" select="$max"/>
> <xsl:with-param name="increment" select="$increment"/>
> </xsl:call-template/>
> </xsl:if>
> </xsl:template>
> puis
> <xsl:call-template name="for">
> <!-- cas particulier : pas besoin de passer $cur et $increment,
> les valeurs par d�faut nous conviennent -->
> <xsl:with-param name="max" select="$lines"/>
> </xsl:call-param>
>
> Tom.
Technical Details
Message-ID:
<9gv61p$i36$1@wanadoo.fr>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!193.251.151.101!opentransit.net!wanadoo.fr!not-for-mailReferences:
<9gt8km$h3r$1@wanadoo.fr> <2170021.3eYUQgxmLv@ltgt.net>Show Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII X-Google-Thread: 114f60,9a3e87b9655eb90b X-Google-Attributes: gid114f60,public X-Google-ArrivalTime: 2001-06-22 03:18:34 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!193.251.151.101!opentransit.net!wanadoo.fr!not-for-mail From: "Romain Guy" <romain.guy@jext.org> Newsgroups: fr.comp.text.xml Subject: Re: XSLT: �quivalent du for ? Date: Fri, 22 Jun 2001 12:21:09 +0200 Organization: Wanadoo, l'internet avec France Telecom Lines: 60 Message-ID: <9gv61p$i36$1@wanadoo.fr> References: <9gt8km$h3r$1@wanadoo.fr> <2170021.3eYUQgxmLv@ltgt.net> NNTP-Posting-Host: alyon-102-1-3-147.abo.wanadoo.fr X-Trace: wanadoo.fr 993205113 18534 193.253.35.147 (22 Jun 2001 10:18:33 GMT) X-Complaints-To: abuse@wanadoo.fr NNTP-Posting-Date: 22 Jun 2001 10:18:33 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200