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



Stéphane Mottelet a écrit :
Daniel Veillard a écrit :
On Mon, Mar 26, 2007 at 03:33:29PM +0200, Stéphane Mottelet wrote:
Hi folks, I am encoutering a problem when using the
function position() with the result of a key().
[...]
            <xsl:value-of select="position(key('match_a','second'))"/>
[...]
Is it  a bug, or am I missing something. I would expect to get the result :

<result>2</result>
 http://www.w3.org/TR/xslt#function-key
 it returns a node-set containing the nodes in the same document as the context node that have a value for the named key equal to this string.

there would be only one element in that node set, so the position can only be 1
so what you wrote is probably not what you expected.

  http://www.w3.org/TR/xpath#function-position

does not take any argument.
Nothing replace checking the docs a bit when learning a new language

Daniel

Yes, I am still learning... But do you know a way to do what I am
expecting ?

S.
I mean something more clever than

   <xsl:template match="doc">
       <result>
           <xsl:for-each select="key('match_a','second')">
               <xsl:value-of select="count(preceding-sibling::*)+1"/>
           </xsl:for-each>
       </result>
   </xsl:template>

S.


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