![]() |
using call templates |
Post Reply
|
| Author | |
GrantDB
Newbie
Joined: 17 Aug 2010 Posts: 2 |
Post Options
Quote Reply
Topic: using call templatesPosted: 17 Aug 2010 at 3:03am |
|
This could be useful as an example of using call-templates
<xfd:xslt-global>
<xfd:xslt xmlns:autn="http://schemas.autonomy.com/aci/" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xc="http://www.ecrion.com/2008/xc" xmlns:xf="http://www.ecrion.com/xf/1.0" xmlns:xfd="http://www.ecrion.com/xfd/1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:z="#RowsetSchema"> <xsl:template name="string-replace-all"> <xsl:param name="text" /> <xsl:param name="replace" /> <xsl:param name="by" /> <xsl:choose> <xsl:when test="contains($text, $replace)"> <xsl:value-of select="substring-before($text,$replace)" /> <xsl:value-of select="$by" /> <xsl:call-template name="string-replace-all"> <xsl:with-param name="text" select="substring-after($text,$replace)" /> <xsl:with-param name="replace" select="$replace" /> <xsl:with-param name="by" select="$by" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text" /> </xsl:otherwise> </xsl:choose> </xsl:template> </xfd:xslt> </xfd:xslt-global>
<!--then use it something like this--> <xsl:variable name="myVar">
<xsl:call-template name="string-replace-all"> <xsl:with-param name="text" select="'This is a sample text : {ReplaceMe} and {ReplaceMe}'" /> <xsl:with-param name="replace" select="'{ReplaceMe}'" /> <xsl:with-param name="by" select="'String.Replace() in XSLT'" /> </xsl:call-template> </xsl:variable> </xfd:xslt>
</xfd:inline-xslt> |
|
![]() |
|
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |