[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: inserting spaces ( )

Subject: Re: inserting spaces ( )
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Tue, 12 Mar 2002 12:25:03 -0800
instead of nbsp
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>&#160;</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 &#160; ??
>
> if <xsl:value-of select="count(ancestor::*)-2"/> is 5 how can i insert 5
> &#160; ?
> thanks
>
> ----- Original Message -----
> From: "stevenson" <stevenson@xxxxxxxxxxxxxxxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Tuesday, March 12, 2002 1:49 PM
> Subject: RE:  inserting spaces (&nbsp;)
>
> > Instead of &nbsp; use &#160;
> >
> > -----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:  inserting spaces (&nbsp;)
> >
> > in html the espace is &nbsp;
> > 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"/> * &nbsp;
> >
> > if the number(<xsl:value-of select="count(ancestor::*)-2"/>) is 5:
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> >
> > 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.