Re: [xsl] configuring a conditional

Subject: Re: [xsl] configuring a conditional
From: Bruce D'Arcus <bdarcus@xxxxxxxxx>
Date: Mon, 23 May 2005 21:54:06 -0400
On May 23, 2005, at 10:38 AM, David Carlisle wrote:

Aside: I've still not worked out HOW to deal with this first/subsequent
business generally.


It's easy enough (although possibly expensive) to know if you are the
first citation to a particular reference, eg you could use xsl:number
and see if you get the number 1, or perhaps better havs an xsl:key that
matches all references, keyed on the reference id then you just have to
ask if the current node is the first node in document order in the
sequence returned by the key for this reference.
so for example if the syntax is

<xref linkend="foo"/>

and you want to know if this is the first such reference

<xsl:key name="xr" match="xref use="@linkend"/>
..
<xsl:template match="xref">

<xsl:if test=". is key('xr',@linkend)[1]">
 I'm first

OK, I tried to implement this in my rather complicated code, but am stuck.


    <xsl:param name="cite-ref" as="element()*"/>
    <xsl:message>
      <xsl:if test="$cite-ref is key('refs',@linkend)[1]">FIRST</xsl:if>
    </xsl:message>

The message is result is always blank.

Since I don't have really any template for db:citation/db:biblioref, I instead pass the cite-ref parameter from the db:citation template where its value is this variable:

<!-- earlier the cite-ref variable was defined as just element(), but
for some reason this yielded an empty-sequence error in one case -->
<xsl:variable name="cite-ref" as="element()*">
<xsl:sequence select="$citation/db:biblioref[@linkend=$id]"/>
</xsl:variable>


Bruce

Current Thread