[xsl] key declarations (using a sequence constructor)

Subject: [xsl] key declarations (using a sequence constructor)
From: Andy Chambers <achambers.home@xxxxxxxxxxxxxx>
Date: Tue, 6 Oct 2009 18:22:04 +0100

I'm playing around with the added features available in key
declarations but I think I must be misunderstanding
something.  Here's my key declaration (I realize that this particular
example would be better as a simple
@use but I want to understand how it works to see if it might make
some of my other keys look a little

  <xsl:key name="keyNames"
		   match="name | mdv">
	<lookup oid="{@oid}"/>

and an example input document is something like...

<timaeus-names xmlns:odm="http://www.cdisc.org/ns/odm/v1.3";>
  <mdv oid="TEST/M/oids" name="TESTMOIDS">
    <name oid="S001" parent-oid="" name="S001" />
    <name oid="F001" parent-oid="S001" name="F001" />
    <name oid="IG001" parent-oid="F001" name="IG001" />
    <name oid="AA.AA" parent-oid="IG001" name="AAAA" />
    <name oid="AA..AA" parent-oid="IG001" name="AAAA2" />
    <name oid="AA...AA" parent-oid="IG001" name="AAAA3" />

I thought that to use this key to lookup the @name associated with
@oid="AA.AA" for example, I'd do

	<xsl:variable name="lookup">
	  <lookup oid="AA.AA"/>
        <xsl:sequence select="key('keyNames', $lookup)/@name"/>

But this actually returns a sequence containing all the @names.

I seek enlightenment as to why this is so :-)


Current Thread