Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 18th, 2004, 11:40 PM
Authorized User
 
Join Date: Oct 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default URGENT:For loop

Hi..
I m new to xslt.
can u please tell me..
How to write the following in xsl

For(i=1 ;i<=n;i++)
{
Add Blank spaces
}


Thanking u in advance
Jyoti


 
Old October 19th, 2004, 06:54 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It depends what you are trying to achieve, there is no direct construct as xslt does not have updateable variables. If you have a node list you want to iterate you can use xsl:for-each.

Microsoft XML docs

By the way nearly everyones' problems are urgent to them.



--

Joe (Co-author Beginning XML, 3rd edition)
 
Old October 19th, 2004, 07:14 AM
Authorized User
 
Join Date: Jul 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

You can use a recursive template.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <xsl:call-template name="addSpaces">
        <xsl:with-param name="count" select="5" />
    </xsl:call-template>
</xsl:template>

<xsl:template name="addSpaces">
   <xsl:param name="count" />
   #xa0;
   <xsl:if test="$count>0">
        <xsl:call-template name="addSpaces">
            <xsl:with-param name="count" select="($count)-1" />
        </xsl:call-template>
   </xsl:if>


</xsl:template>

</xsl:stylesheet>

Regards

Bryan

 
Old October 19th, 2004, 08:04 AM
Authorized User
 
Join Date: Oct 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot Bryan and Joe.
My problem is solved by implementing the template that Bryan has suggested.

Regds
Jyoti






Similar Threads
Thread Thread Starter Forum Replies Last Post
While loop urgent mikedeepak Classic ASP Databases 1 October 7th, 2005 03:04 AM
Do Loop junemo Beginning PHP 8 July 28th, 2004 02:58 AM
Problem with Loop?? Please URGENT peterallcdn Beginning PHP 1 November 27th, 2003 06:37 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.