Subject: Re: [xsl] inserting spaces ( ) From: Peter Davis <pdavis152@xxxxxxxxx> Date: Tue, 12 Mar 2002 12:25:03 -0800 |
Use a recursive template. It works just like a normal for-loop, but instead of going back to the beginning of the loop each time, you call the same template again with the count one less than it was before. Then you stop processing when the count reaches zero. Something like this: ... <xsl:call-template name="output-ancestor-spaces"/> ... <xsl:template name="output-ancestor-spaces"> <!-- the select gives the default value of this param --> <xsl:param name="count" select="count(ancestor::*)-2"/> <xsl:if test="count > 0"> <xsl:text> </xsl:text> <xsl:call-template name="output-ancestor-spaces"> <xsl:with-param name="count" select="$count - 1"/> </xsl:call-template> <xsl:if> </xsl:template> This is pretty standard, you should check out the archives for about a million-and-a-half other examples on recursive templates. Also, if you don't like the syntax above, you could try the XSLT Loop Compiler which has a more familiar for- or while-loop style syntax: http://www.informatik.hu-berlin.de/~obecker/XSLT/loop-compiler/ On Tuesday 12 March 2002 05:55, Carlos wrote: > well but how can i insert <xsl:value-of select="count(ancestor::*)-2"/> > numbers of   ?? > > if <xsl:value-of select="count(ancestor::*)-2"/> is 5 how can i insert 5 >   ? > thanks > > ----- Original Message ----- > From: "stevenson" <stevenson@xxxxxxxxxxxxxxxxxxxxxx> > To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> > Sent: Tuesday, March 12, 2002 1:49 PM > Subject: RE: [xsl] inserting spaces ( ) > > > Instead of use   > > > > -----Original Message----- > > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Carlos > > Sent: 12 March 2002 15:04 > > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > > Subject: [xsl] inserting spaces ( ) > > > > in html the espace is > > if with <xsl:value-of select="count(ancestor::*)-2"/> i have a number, > > how can i insert this number * spaces? > > --> <xsl:value-of select="count(ancestor::*)-2"/> * > > > > if the number(<xsl:value-of select="count(ancestor::*)-2"/>) is 5: > > > > > > thanks > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list -- Peter Davis Noncombatant: A dead Quaker. -- Ambrose Bierce XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] inserting spaces ( ), Carlos | Thread | RE: [xsl] inserting spaces ( ), Michael Kay |
Re: [xsl] position in the tree, Joerg Heinicke | Date | [xsl] adding variables, bryan hansen |
Month |