Hi
You may try to find the answer for your question at 'XSLT Questions and
Answers' (http://www.dpawson.co.uk/xsl/sect21.html).
One of the part of this FAQ is 'Things XSLT can't do'
(http://www.dpawson.co.uk/xsl/nono.html).
The question 13. 'Variable reference in the match attribute of a template.'
-----------------------------------------------------
you can't have any variable reference in the match attribute of a template.
First para, 5.3 of xslt spec. E.g. you can't have
<xsl:template match="p[. = $head-types]">
(Ken H adds Although XT accepts the above, it is one of the areas where
error checking is not fully implemented.)
In general in XSLT you can't use variables to contain expressions, patterns,
or parts thereof, you can only use them to hold strings, numbers, node-sets,
and booleans.
You can probably use count="*[name()=$element]", if you're careful about
namespaces. <xsl:number> is the one place in XSLT where variables can be
used within a predicate that forms part of a pattern.
-----------------------------------------------------
PS
Your code:
<xsl:with-param name="type" select="LDD"/>
May be you mean:
<xsl:with-param name="type" select="'LDD'"/>
????
With best regards,
Alexander Veremyev.
-----Original Message-----
From: Frank Sijbers [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 25, 2001 5:07 PM
To: Sablotron Mailing List
Subject: [Sab] avoiding the key function
Hello,
I want to se a for-each loop which uses a variable as select statement, but
I just don't find a way to do it.
e.g.:
xml document:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<LDD Status="0">
<blablabla/>
</LDD>
<FDD Status="1">
<blablabla/>
</FDD>
</root>
xsl stylesheet:
<!---code -->
<xsl:choose>
<xsl:when test="$type_to_check = LDD">
<xsl:call-template name="checkstatus">
<xsl:with-param name="type"
select="LDD"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$type_to_check = FDD">
<xsl:call-template name="checkstatus">
<xsl:with-param name="type"
select="FDD"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
<!---code -->
<xsl:template name="checkstatus">
<xsl:param name="type"/>
<xsl:variable name="nodeset"
select="concat('/root/',$type,'/@Status')"/>
<xsl:for-each select="$nodeset">
<!-- do something-->
</xsl:for-each>
</xsl:template>
How can I make my xslt processor clear to use the nodeset defined by
$nodeset?
thx
Frank
PS if you think I ask this question in the wrong mailinglist, please point
me to the correct one.