Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: Phillip B Oldham <phillip.oldham@---------->
To:
Date: 6/1/2006 6:53:00 AM
*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!


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent