xsl-list
[Top] [All Lists]

Re: variable binding

2003-11-05 15:35:45

but when I try to run it, it tells me that the variable branch has not
been declared, even though it should first have processed the first
daughter of ng, where it has been declared.


This is because you've only defined branch within the priority="5" template,
so it will only be scoped there.  You also need to scope it within the
priority="4" template:

<xsl:template match="s//ng//*" priority="4">
  <xsl:variable name="branch">right</xsl:variable>
  <xsl:copy>
    <xsl:attribute name="branch"><xsl:value-of
select="$branch"/></xsl:attribute>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

Question:  is $branch always equal to "right"?  If so, you can define the
variable at the "top" i.e. as a direct child of the xsl:stylesheet element.
Then it will be scoped throughout...

...sam


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>