8.4. Comparing <xsl:variable> and <xsl:param>

Syntactically, there is no difference between <xsl:variable> and <xsl:param>. The content model of both elements is the same. The way these elements declare variables is the same. However, the value of the variable declared using <xsl:param> is only a default that can be changed with the <xsl:with-param> element, while the <xsl:variable> value cannot be changed. The only other difference is that there is a restriction on where the <xsl:param> element can be used. It must always come before any other elements if used within a template rule.

Because <xsl:variable> and <xsl:param> declare variables in the same way, if they are both present in the same context and they both have the same name, they are considered duplicates and result in an error. Duplicate declarations, or shadowing, are discussed in Section 8.3.2.

Using <xsl:param> together with <xsl:variable> raises certain contextual restrictions on syntax. When a variable and parameter are both declared in a template, the <xsl:param> must come first.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.51.117