Posts

Showing posts from July, 2014

Using parameters in XSLT

If you've read some of my previous posts, you've seen examples of using parameters when calling templates. I earlier wrote about assigning XML structures to variables. Now we are going to use a variable as parameter for a template call. Create the variable and send it as a parameter to your template of choice: <!-- Given a structure like this one... --> <xsl:variable name="someVariable"> <record> <artist sex="female">Madonna</artist> <title>Like a prair</title> </record> </xsl:variable> <xsl:call-template name="targetTemplate"> <xsl:with-param name="string" select="$someVariable" /> <xsl:with-param name="attributeString" select="$someVariable/@sex"/> </xsl:call-template name="targetTemplate"> </xsl:template> Grab the variable and do something that makes sense. ;