[xsl] apply-templates select and current() question

Subject: [xsl] apply-templates select and current() question
From: "Bruce D'Arcus" <bdarcus@xxxxxxxxx>
Date: Wed, 18 May 2005 22:42:38 -0400
I'm trying to implement citation processing where citations basically
treated as if they were footnotes; rendered and numbered the same.

So I created a union template in its own mode like so, which is close
to working correctly.

  <xsl:template match="db:footnote | db:citation" mode="footcite">
    <xsl:variable name="incr">
      <xsl:number level="any" count="db:footnote |
db:citation[not(../db:footnote)]"/>
    </xsl:variable>
    <p id="fn{$incr}">
      <a href="#fnm{$incr}" class="footnote-anchor">
        <xsl:value-of select="$incr"/>
      </a>
      <xsl:text>. &#xa0;</xsl:text>
      <xsl:apply-templates select="if (current() = db:footnote) then *
else ."/>
    </p>
  </xsl:template>

The above select statement is supposed to:

	-	if current() is db:citation apply-templates to itself in the default
mode
	-	if current() is db:footnote, then just do the standard
apply-templates to the children

However, for the latter I end up with this:

2. [1]

.. which tells me that even though the current() for the this element
is in fact db:footnote, the select is "."

If I change the select statement to just "*", then that part gets
rendered correctly.

If I change the statement to "if (../db:footnote) then * else ." then
it also seems to work (there's one problem that I think is unrelated).

So what's going on??

Bruce

Current Thread