[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: A beautiful way to populate a variable with N blan
A static way to do this (even in XPath 1.0) is when you know an upper bound for N. Say N <= 1000, then you have a variable: <xsl:variable name="longBlanks" select="' '" /> <!-- 1000 spaces there --> Then we construct any needed such value simply as: substring($longBlanks, 1, $N) Thanks, Dimitre On Fri, Feb 24, 2023 at 6:43 AM Roger L Costello costello@xxxxxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > Hi Folks, > > $N contains an integer. > > $blanks is a string variable. The string is to consist of $N blanks (space > characters). > > Below is one way to populate $blanks. It's an awful solution. Is there a > beautiful (simple) solution? > > <xsl:variable name="tmp" as="xs:string+"> > <xsl:sequence select="''" /> > <xsl:sequence select="for $i in 1 to $N return (' ')"/> > </xsl:variable> > > <xsl:variable name="blanks" as="xs:string"> > <xsl:value-of select="$tmp" separator=""/> > </xsl:variable>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|