[xslt] using key() function with key name in a variable

I'm using the key() function (via xsltproc) and supplying the key name in 
a variable.

This works if the variable contains a string (such as)
        <xsl:variable name="k" select="'keyname'"/>

However, if the variable contains an RTF, such as
        <xsl:variable name="k">
                        <xsl:when test="sometest">keyname1</xsl:when>
then using
        key( $k, ... )
gives the error
        runtime error: file gbs_log_show_all.xsl line 187 element variable
        key() : invalid arg expecting a string
        key( string($k), ... )
works ok.

I've tried the same thing in saxon, mozilla and msxml and they all seem to 
work when $k contains the RTF (without needing the string() function). 
Looking at the xslt rec, it doesn't seem to say much about the first 
parameter to key() other than that it's a string and a QName.

Didn't find anything in the archives and I don't remember seeing anything 
like this on xslt-list, so I don't know whether to report this as a bug or 
not, but it seems to act differently to several other xslt processors.

I'm using

xsltproc -V
Using libxml 20421, libxslt 10017 and libexslt 708
xsltproc was compiled against libxml 20421, libxslt 10017 and libexslt 708
libxslt 10017 was compiled against libxml 20421
libexslt 708 was compiled against libxml 20421

regards, John Escott.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]