This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:when problem
- To: Eric Taylor <Eric dot Taylor at RealPage dot com>
- Subject: Re: xsl:when problem
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 18 Aug 2000 14:08:02 +0100
- Cc: "'XSL-List at mulberrytech dot com'" <XSL-List at mulberrytech dot com>
- Reply-To: xsl-list at mulberrytech dot com
Eric,
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:choose>
<xsl:when test=".[@internal = //bookmark/@name]">
<A>
<xsl:attribute name="href">#<xsl:value-of select="@internal"
/></xsl:attribute>
<xsl:value-of select="@text"/>
</A>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
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
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list