Ecrion Software Inc. Homepage
Forum Home Forum Home > XF Rendering Server > Sample Code
  New Posts New Posts RSS Feed: using call templates
  FAQ FAQ  Forum Search   Register Register  Login Login

using call templates

 Post Reply Post Reply
Author
Message / View First Unread Post
GrantDB View Drop Down
Newbie
Newbie


Joined: 17 Aug 2010
Posts: 2
Post Options Post Options   Quote GrantDB Quote  Post ReplyReply Direct Link To This Post Topic: using call templates
    Posted: 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-->
<xfd:inline-xslt>
     <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: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>
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz

This page was generated in 0.063 seconds.