Efi Merdler wrote:
As I understand it is impossible in xslt to change the value of a
variable after you assigned a value to it.
That is true.
I would like to simulate a flag. For example
if something happens in template A then update my flag.
Template B reads the flag and according to its value decides to do
something.
The main idea is that template B is independent of template A, i.e.
template A does not call it directly.
You can pass parameters to templates e.g.
<xsl:apply-templates select="foo">
<xsl:with-param name="flag" select="true()"/>
</xsl:apply-templates>
<xsl:template match="foo">
<xsl:param name="flag" select="false()"/>
...
</xsl:template>
With XSLT 1.0 you would need to ensure that the parameter is passed on
to all templates involved, with XSLT 2.0 you could make use of a tunnel
parameter e.g.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="text"/>
<xsl:template match="/root">
<xsl:apply-templates select="foo">
<xsl:with-param name="flag" select="true()" tunnel="yes"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="foo">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="bar">
<xsl:param name="flag" select="false()" tunnel="yes"/>
<xsl:sequence select="$flag"/>
</xsl:template>
</xsl:stylesheet>
Although the template matching foo does not have an xsl:param the tunnel
parameter named flag is passed on to the template matching bar.
There are three XSLT 2.0 implementations currently, one is Saxon from
<URL:http://saxon.sourceforge.net/>, on is Altova XML tools, one is
Gestalt <URL:http://sourceforge.net/project/showfiles.php?group_id=124274>.
--
Martin Honnen
http://JavaScript.FAQTs.com/