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

Executing an alternate template if select="somepath" r

Subject: Executing an alternate template if select="somepath" returns no nodes.
From: Adam Van Den Hoven <Adam.Hoven@xxxxxxxxxxxx>
Date: Tue, 9 Jan 2001 10:40:55 -0800
if select
I have a relatively simple question. I've already found a solution that
works for my current situation but I'm looking for a more general solution.

In my XSL, I originally had the following:

...
<xsl:apply-templates select="library/playlist[@current='current']" />
...

<xsl:template match="library/playlist[@current='current']">...
</xsl:template>

Which isn't really all that big a deal (ok, it may be redundant the way its
written but its actually someone else's code). But I need to be able to call
a different template when there is no playlist with the attribute current
equal to current. In this case, the stuff that needed to be done if there
wasn't the playlist happened to also be in the template that executes when
there is a playlist so I rewrote the code to be
...
<div id="used_to_be_in_the_template">
	<xsl:apply-templates />
	<xsl:call-template name="common" />
</div>
...
<xsl:template match="playlist[@current='current']">... </xsl:template>
<xsl:template name="common">... </xsl:template>
 (since there is no other template that will match a playlist, this works
fine, otherwise a simple mode will fix it)

But what I want to know is whether there is a way to ensure that if the
select returns no nodes that template foobar gets called. I know that I
could use a choose/when/otherwise approach but it seems inelegant to me. 

Thanks everyone. 


> 		Adam van den Hoven
> 		Internet Application Developer
> 		Blue Zone
> 		tel. 604.685.4310
> 		fax. 604.685.4391
> 
> Blue Zone makes you interactive. http://www.bluezone.net/
> 
> 
> 
> 

 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.