Create an array in xslt

You can create any data type model you want to in xslt.

To create an array, just create a variable for it.

<xsl:stylesheet version="2.0" xmlns:xsl="">
    <xsl:output method="text" omit-xml-declaration="yes"/>
    <xsl:variable name="array" as="element()*">
    <xsl:template match="/">
        <xsl:value-of select="$array[2]"/>




How to access a variable from within xsl:for-each from outside xsl:for-each

You must have used variables in xslt, like how easy it is to use them anywhere.

In the same way you can also wrap xsl: for-each with an xsl: variable.

For example, the following stylesheet declares a variable EmployeeName and within the xsl: for-each it uses xsl: value-of and xsl: text.

All of the text values are assigned to the variable EmployeeName, which is used outside of the xsl: for-each to select it’s value.

We will use the following xml, for example :



And here is the code for xslt –




%d bloggers like this: