1

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

2 Answers 2

2
<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
Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.