posted 22 years ago
xsl:variable and xsl:param
Both can be defined inside template, or be a top-level element - i.e. defined as a child of xsl:stylesheet element.
but
xsl:variable is also allowed anywhere within a template where an instruction is allowed, xsl:param not. For example, you can define xsl:variable inside xsl:if element, which wont work for xsl:param.
They have very similar functionality, xsl:param is just another way to implement a variable. The main difference is that xsl:param can get its value from "the calling environment": you specify parameters when calling a stylesheet. For this technique to work, xsl:param must be a child of xsl:stylesheet element, not xsl:template.
Regarding scope, what Vasudha said is true, I would only add that in case of xsl:variable its scope can be even narrower. If it is declared inside some other instruction, like aforementioned xsl:if - then it's scope is this instruction and you cannot access the variable outside of xsl:if construction.