Xml variable in Xslt

08/12/2012 14:48

 

<?xml version="1.0" encoding="utf-8"?>

    <xsl:stylesheet version="1.0"

        xmlns:xsl="https://www.w3.org/1999/XSL/Transform"

        xmlns:msxsl="urn:schemas-microsoft-com:xslt">

 

        <xsl:variable name="xmlCats">

            <Cat>First</Cat>

            <Cat>Second</Cat>

        </xsl:variable>

        <xsl:param name="xmlCategories" select="msxsl:node-set($xmlCats)"/>

 

        <xsl:template match="/">

            <html>

                <body>

                    <h2>Xml Variable and Access</h2>

                    <xsl:value-of select="$xmlCategories/Cat[2]"/>

                    <br></br>

                    <xsl:value-of select="$xmlCategories"/>

                </body>

            </html>

        </xsl:template>

 

</xsl:stylesheet>

 

Result:

 

Xml Variable and Access

Second
FirstSecond