Re: [xsl] configuring a conditional

Subject: Re: [xsl] configuring a conditional
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 24 May 2005 10:55:52 -0400
Hi Bruce,

At 09:54 PM 5/23/2005, you wrote:
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.

The question I'd ask is what's @linkend. This of course depends on what the context node is -- so we need to consider where this appears.


XSLT 2.0 functions work different from templates in that they don't have a context node (or position or size) ... instead of relying on being able to traverse from the context node to its @linkend attribute, for example, you have to pass the node in and then traverse to $node/@linkend.

Could this be an issue here? We need to see more code. But guessing out of the blue (that is, guessing you are defining a function here) I suppose you might try test="$cite-ref is key('refs',$cite-ref/@linkend)[1]".

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread