This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: testing the current node in IF statements
- To: xsl-list at mulberrytech dot com
- Subject: Re: testing the current node in IF statements
- From: Wendell Piez <wapiez at mulberrytech dot com>
- Date: Fri, 04 Feb 2000 11:11:56 +0000
- Reply-To: xsl-list at mulberrytech dot com
At 02:01 PM 2/4/00 -0000, Peter Bennet wrote:
>what I really want to do now is use the same idea for the node itself
>i.e..
>
><xsl:template match="book | chapter">
> <xsl:if test="self='book'">
> instructions
> </xsl:if>
> <xsl:if test="self='chapter'">
> different instructions
> </xsl:if>
> some instructions common to both
></xsl:template>
>...
Well, a way to do what you want would be to resort to string testing
against the nefarious local-name(), as in:
<xsl:template match="book | chapter">
<xsl:if test="local-name()='book'">
instructions
</xsl:if>
<xsl:if test="local-name()='chapter'">
different instructions
</xsl:if>
some instructions common to both
</xsl:template>
But a better way to achieve the same result might be to split your logic
into separate templates after all:
<xsl:template name="common-instructions">
some instructions common to both
</xsl:template>
<xsl:template match="book">
book instructions
<xsl:call-template name="common-instructions"/>
</xsl:template>
<xsl:template match="chapter">
chapter instructions
<xsl:call-template name="common-instructions"/>
</xsl:template>
Have fun--
Wendell Piez
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
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
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list