xsl-list
[Top] [All Lists]

Re: [xsl] "Return" from a function?

2006-05-31 23:53:00
*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!


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>