Reputation: 1599
I want to implement array like structure.The prototype of my need is
<xsl:variable name="alphabets">abcdefghijklmnopqrstuvwxyz</xsl:variable>
When i give input as 4, i should get 'd'. How to implement this..please help me.. Thanks in advance
Upvotes: 1
Views: 771
Reputation: 163262
XSLT 2.0 supports sequences, which allow you to do
<xsl:variable name="alphabet" select="'a', 'b', 'c', ...."/>
<xsl:value-of select="$alphabet[4]"/>
In XSLT 1.0, for an "array of characters" as in your example, use a string. For more complex structures, use an XML element with child elements.
Upvotes: 2
Reputation: 5892
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="alphabets" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:param name="vAlphIndex" select="4"/>
<xsl:template match="/*">
<xsl:value-of select="substring($alphabets, $vAlphIndex, 1)"/>
</xsl:template>
</xsl:stylesheet>
Result will be:
d
Upvotes: 2