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

Re: "Return" from a function?

Subject: Re: "Return" from a function?
From: Phillip B Oldham <phillip.oldham@xxxxxxxxxx>
Date: Thu, 01 Jun 2006 07:52:43 +0100
what is meant by templates
*David:* Yes, sorry - I meant <xsl:template />.

Thinking procedurally, what I'd like to do is something like:

<xsl:template match="/subscriptions/item">
<xsl:if test="not(renewaldate)">
<p>Sorry, there has been an error...</p>
<xsl:return />
</xsl:if>
<!-- otherwise execute the rest of the stuff below -->
<p>Your renewal date for <xsl:value-of select="subscriptionname" /> is: <xsl:value-of select="renewaldate" />.</p>
</xsl:template>


Though, thinking about it, I suppose I could do something like the following (thanks *Andrew*):

<xsl:template match="/subscriptions/item[renewaldate]">
<p>Your renewal date for <xsl:value-of select="subscriptionname" /> is: <xsl:value-of select="renewaldate" />.</p>
</xsl:template>


<xsl:template match="/subscriptions/item[not(renewaldate)]">
<p>Sorry, there has been an error...</p>
</xsl:template>

Feels weird though, because actions for the same element aren't being kept "together" (within the same template), but it does look more useful than a return.

*Andrew:* Yes, I started off doing a lot of for-each loops. I'm using apply-template as much as I can... but I do revert a lot. ;) My nightmare is using call-template all over the place. Really does slow things down. I try to use it only for "includes" now, and for processing nodesets and returning a value. I've heard that you can create a custom function to be used in XPath using call-templates, but I've not found much documentation on it yet. :(

Anyway... Thanks guys!

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-2007 All Rights Reserved.