|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Variables within templates
> So, if a variable should be visible "for all following siblings and their
> descendants." why I am getting the error?
because that refers siblings and descendants of the <xsl:variable>
element in the XML tree of the stylesheet.
so in here
<xsl:for-each select="invoices/invoice">
<xsl:variable name="language" select="@xml:lang" />
<xsl:apply-templates />
</xsl:for-each>
the variable scope applies only to the <xsl:apply-templates element
(so you could have used $langauge in a select expression on that
element)
but that is all. The other templates are not in this scope.
If you want to pass information down the recursive apply-templates call,
then you need to make it a parameter to the templates
<xsl:for-each select="invoices/invoice">
<xsl:apply-templates>
<xsl:with-param name="language" select="@xml:lang" />
</xsl:apply-templates>
</xsl:for-each>
and declare language to be a param of any templates that need to use it.
However it is probably simpler in this case not to pass this information
down via a parameter, and just go back up the tree to get the
information when you need it. that is
<xsl:for-each select="invoices/invoice">
<xsl:apply-templates />
</xsl:for-each>
and then
<xsl:template match="invoice_number">
<xsl:value-of select="/invoices/translations/invoice_no
[@xml:lang= current()/../@xml:lang]" />
: <xsl:value-of select="." />
</xsl:template>
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








