Re: [xslt] problem with key and position() function

Please forgive my ignorance, I realized that the result of the function
key(), even if it is a single node,  has no context nodeset. Hence the
position() function cannot return anything. But the error message
is not explicit at all...


Stéphane Mottelet a écrit :
Hi folks, I am encoutering a problem when using the
function position() with the result of a key().

Here is the xml file to process :

<?xml version="1.0" encoding="ISO-8859-1"?>
    <a id="first"/>
    <a id="second"/>

Here is the stylesheet :

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl=""; version="1.0">
     <xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>
    <xsl:key name="match_a" match="a" use="@id"/>
<xsl:template match="/">

    <xsl:template match="doc">
            <xsl:value-of select="position(key('match_a','second'))"/>

Here is what i got when launching the transformation :

portmottelet-hz-1:~$ xsltproc test.xsl test.xml
XPath error : Invalid number of arguments
runtime error: file test.xsl line 16 element value-of
xsltValueOf: text copy failed
no result for test.xml

Is it  a bug, or am I missing something. I would expect to get the result :


Thanks for help

Using libxml 20616, libxslt 10111 and libexslt 809
xsltproc was compiled against libxml 20616, libxslt 10111 and libexslt 809
libxslt 10111 was compiled against libxml 20616
libexslt 809 was compiled against libxml 20616

xslt mailing list, project page
xslt gnome org

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