G
Giacomo
I need to iterate over the letters of the alphabet; the only solution I
found using only XSLT 1.0 is:
<xsl:key name="hostnames" match="host/name" use="substring(., 1, 1)" />
<my:alphabet xmlns:my="my.com">
<l>a</l><l>b</l><l>c</l><l>d</l><l>e</l><l>f</l><l>g</l><l>h</l><l>i</l><l>j</l><l>k</l><l>l</l><l>m</l><l>n</l><l>o</l><l>p</l><l>q</l><l>r</l><l>s</l><l>t</l><l>u</l><l>v</l><l>w</l><l>x</l><l>y</l><l>z</l>
</my:alphabet>
<xsl:variable name="root" select="/"/>
<xsl:variable name="alphabet" select="document('')/*/my:alphabet/l"/>
<xsl:template name="summary">
...
<!--this works, but I don't need it -->
<xsl:for-each select="$root">
<xsl:apply-templates select="key('hostnames','b')" />
</xsl:for-each>
<!--this doesn't work and I need it!!! -->
<xsl:for-each select="$alphabet">
<xsl:variable name="letter" select="." />
<xsl:for-each select="$root">
<xsl:value-of select="$letter" />: <xsl:apply-templates
select="key('hostnames','a')" />
</xsl:for-each>
</xsl:for-each>
</xsl:template>
What can I do?
Thanks,
Giacomo.
found using only XSLT 1.0 is:
<xsl:key name="hostnames" match="host/name" use="substring(., 1, 1)" />
<my:alphabet xmlns:my="my.com">
<l>a</l><l>b</l><l>c</l><l>d</l><l>e</l><l>f</l><l>g</l><l>h</l><l>i</l><l>j</l><l>k</l><l>l</l><l>m</l><l>n</l><l>o</l><l>p</l><l>q</l><l>r</l><l>s</l><l>t</l><l>u</l><l>v</l><l>w</l><l>x</l><l>y</l><l>z</l>
</my:alphabet>
<xsl:variable name="root" select="/"/>
<xsl:variable name="alphabet" select="document('')/*/my:alphabet/l"/>
<xsl:template name="summary">
...
<!--this works, but I don't need it -->
<xsl:for-each select="$root">
<xsl:apply-templates select="key('hostnames','b')" />
</xsl:for-each>
<!--this doesn't work and I need it!!! -->
<xsl:for-each select="$alphabet">
<xsl:variable name="letter" select="." />
<xsl:for-each select="$root">
<xsl:value-of select="$letter" />: <xsl:apply-templates
select="key('hostnames','a')" />
</xsl:for-each>
</xsl:for-each>
</xsl:template>
What can I do?
Thanks,
Giacomo.