Re: [xsl] use-when attribute?

Subject: Re: [xsl] use-when attribute?
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Sat, 18 Dec 2004 07:43:36 -0500
On Dec 18, 2004, at 5:30 AM, Geert Josten wrote:

you could use the following:

<xsl:key name="citerefs" match="db:biblioref/@linkend" use="'all'" />
<xsl:key name="citerefs" match="cite:biblioref/@cite:key" use="'all'" />
<xsl:key name="citerefs" match="tei:cit/@href" use="'all'" />


And use key('citerefs', 'all') instead of $citerefs..

I was originally using keys (at your suggestion, in fact), but Mike Kay at one point seemed to suggest it better for my purposes to use a variable. I didn't quite understand why, but here's his explanation:


====
I don't really see what a key with a constant "use" expression achieves.
Apart from the fact that it applies to whichever document is current at the
time, you could just as well (and probably better) use a global variable


<xsl:variable name="citekey" select="//db:biblioref/@linkend"/>
====

The code subsequently gets used in these two variables:

<!--+ ==============================================================
| create a table against which to measure relative citation position
+-->
<xsl:variable name="cite-position">
<bib:refs>
<bib:all>
<xsl:for-each select="$citerefs">
<bib:ref position="{position()}" id="{generate-id()}" key="{.}"/>
</xsl:for-each>
</bib:all>
<bib:unique>
<xsl:for-each-group select="$citerefs" group-by=".">
<bib:ref position="{position()}" id="{generate-id()}" key="{.}"/>
</xsl:for-each-group>
</bib:unique>
</bib:refs>
</xsl:variable>
<!--+ ==============================================================
| construct a list of unique references to pass to a query
+-->
<xsl:variable name="citekeys">
<xsl:text>(</xsl:text>
<xsl:for-each-group select="$citerefs" group-by=".">
<xsl:if test="position() &gt; 1">,%20</xsl:if>
<xsl:text>'</xsl:text>
<xsl:value-of select="."/>
<xsl:text>'</xsl:text>
</xsl:for-each-group>
<xsl:text>)</xsl:text>
</xsl:variable>


Bruce

Current Thread