Michael Kay wrote:
Why Saxon doesn't allow to use variables in template declarations ?

Because the spec doesn't allow them.

Why doesn't the spec allow them? Because they can cause circular
definitions. For example

<xsl:variable name="a">
<xsl:apply-templates select="//x"/>
</xsl:variable>

<xsl:template match="x[@att=$a]">
...
</xsl:template>

<xsl:template match="x[@att!=$a]">
...
</xsl:template>

However, the spec doesn't succeed in preventing circularity, because you can
still write:

<xsl:variable name="a">
<xsl:apply-templates select="//x"/>
</xsl:variable>

<xsl:template match="x">
<xsl:if test="@att=$a">
...
</xsl:template>

So in my view the restriction was probably a mistake. But Saxon will conform
to the spec, whether I like th e spec or not.

Mike Kay
Thank you Mike for those explanations.
So, I conclude there is no way but this one :
<xsl:template match="*[namespace-uri()=namespace-uri(myns:foo)]"> ... 

And now, what about matching a parameter passed to the stylesheet ? :

<xsl:template match="*[namespace-uri()=$stylesheet-param]"> ...

I mean, I don't know how to implement it in an other way because the
namespace used is known by another stylesheet. (I get a lot of problems
here because of this §5.3 spec chapter)


I attach 2 stylesheets of the Cocoon 2 project (the author : Sylvain is
a colleague of mine). In this case, Xalan (actual release) works perfectly well
(but don't respect the spec !) and Saxon (6.4.4) does something very
strange : instead of warning about the use of a variable in the template
match attribute, it doesn't match the template at all and run without warning.

Now, I ask to myself two questions :
- Why Sylvain doesn't obtain the Saxon warning I obtained with my stylesheet
(see the first ex ample I wrote yesterday) ?
- How to implement it with this spec restriction to make it work also with Saxon ?


Thank you

.Thibs.
Anyware Technologies
http://www.anyware-tech.com