[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: testing the current node in IF statements

Subject: Re: testing the current node in IF statements
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 04 Feb 2000 11:11:56 +0000
xsl manual self name
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@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
======================================================================


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.