[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] "Return" from a function?
Subject: Re: [xsl] "Return" from a function?
From: Phillip B Oldham <phillip.oldham@xxxxxxxxxx>
Date: Thu, 01 Jun 2006 07:52:43 +0100
|
*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!
|