Re: [xsl] key() and ordering of resulting node-set

Subject: Re: [xsl] key() and ordering of resulting node-set
From: Ronan Klyne <ronan.klyne@xxxxxxxxxxx>
Date: Thu, 16 Nov 2006 12:02:03 +0000
Michael Kay wrote:
>> XT is putting the menus in reverse order.
> Show us some code, and we can tell you if you've found a bug in XT.

I'm leaving out the bulk of the code, because it's not interesting, and
I don't think it's important for this problem.
'artifact-entry-actions' should produce an <a> element with
onmouseover/out actions to call up the appropriate menu. The appropriate
menu is selected by position().
the code generateing menus uses position() too, but the ordering comes
from the result of key().
I hope it's clear how these templates match up with each other.

The code generating the item listing (will be in document order, yes?):

<xsl:template name="get-all-entries">
  <xsl:apply-templates select="ARTIFACT/ARTIFACT"/>


<xsl:template name="artifact-entry-actions">
  <xsl:param name="notifyextra" select="0"/>
  <xsl:variable name="pos" select="position()+$notifyextra+6"/>
  <A HREF="javascript:void(null)"
    onMouseOver="{concat('BC_PopUp(', $snglq, $pos, $snglq, ',event);
return true')}"
    onMouseOut="{concat('BC_PopDown(', $snglq, $pos, $snglq, '); return

    <IMG WIDTH="13" HEIGHT="13" BORDER="0" ALT="Click for Actions"
NAME="{concat('menu', $pos)}">
      <xsl:attribute name="SRC">
        <xsl:value-of select="$ImgDir"/>


The code generating the menus:

<xsl:key name="artifact_id-subartifacts" match="//ARTIFACT/ARTIFACT"


{This is in a template:}

    <xsl:for-each select="key('artifact_id-subartifacts',

      <xsl:value-of select="position()+6"/>
      <xsl:text> = [[120,]</xsl:text>

<!-- Generate menu javascript here. -->

I believe I have included the pertinent sections...

	# r

Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555

Current Thread