Re: [xsl] looping over a string?

Subject: Re: [xsl] looping over a string?
From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Date: Mon, 23 Jan 2006 16:06:29 +0100
> I suspect I can define a chunk of xml inside the xsl, assigning it to a
> variable, and somehow apply templates to that?
>
The easiest way would then be to use this:

<xsl:variable name="Alphabet-as-RTF">
  <Alphabet>
    <Letter>A</Letter>
    <Letter>B</Letter>
    ...
    <Letter>Z</Letter>
  </Alphabet>
</xsl:variable>

Depending on whether your processor supports xx:nodeset extension, you
can use either that, or you can use another variable, referencing the
first (David Carlisle has provided me with this solution in the past):

<xsl:varible name="Alphabet-as-nodeset"
select="document('')/xsl:stylesheet/xsl:variable[@name='Alphabet-as-RTF']"/>

Then you can reference this variable with an xsl:for-each or other
construct to iterate over the letters in the alphabet.

I hope this helps.

Regards,
Ragulf Pickaxe :-)

Current Thread