Re: xsl:when problem

Subject: Re: xsl:when problem
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 18 Aug 2000 14:08:02 +0100

xsl:when and xsl:otherwise are meant to go inside xsl:choose.  Your
template should be:

<xsl:template match="link">
  <xsl:if test="@internal">
      <xsl:when test=".[@internal = //bookmark/@name]">
          <xsl:attribute name="href">#<xsl:value-of select="@internal"
          <xsl:value-of select="@text"/>
        <xsl:value-of select="@text"/>

I haven't tested this with the old version of MSXML.

The test expression '.[@internal = //bookmark/@name]' tests to see whether
there are any nodes that are the current node that have an 'internal'
attribute with the same value as the 'name' attribute of any 'bookmark'
element in the document.  In effect, this is testing whether the 'internal'
attribute of the current node has the same value as the 'name' attribute of
any 'bookmark' element, and should probably just be '@internal =
//bookmark/@name' to save a bit of processing.

[Also, if you were using a more up-to-date version of MSXML, then you could
use attribute value templates instead of xsl:attribute.]

I hope that this helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread