[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Getting values from different templates

Subject: RE: Getting values from different templates
From: T Uma Shankari <umashankari@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 10 Jan 2006 15:59:47 +0530 (IST)
xsl substring contains
Here i have pasted partial of the code. I am replacing {sub} to <sub> and {/sub} to </sub>

Code to retrieve contents before this symbol '|'
-------------------------------------------------------------

<xsl:template match="content">
     <xsl:variable name="string11">
       <xsl:value-of select="substring-before(.,'|')"/>
     </xsl:variable>
   <xsl:if test="(contains($string11,'{sub}'))">
    <xsl:call-template name="replacebeforesub">
       <xsl:with-param name="string1" select="$string11"/>
     </xsl:call-template>
  </xsl:if>
</xsl:template>

<xsl:template name="replacebeforesub">
  <xsl:param name="string1"/>
     <xsl:variable name="string11">
   <xsl:if test="(contains($string1,'{sub}'))">
    <xsl:value-of select="substring-before($string1,'{sub}')"/>
       <sub>
         <xsl:value-of select="substring-before(substring-after($string1,'{sub}'),'{/sub}')"/>
        </sub>
     <xsl:value-of select="substring-after($string1,'{/sub}' )" />
    </xsl:if>
     </xsl:variable>
    <xsl:if test="(contains($string1,'{sub}'))">
     <xsl:call-template name="replacebeforesub">
      <xsl:with-param name="string1" select="$string11"/>
    </xsl:call-template>
   </xsl:if>
   <xsl:if test=3D"not((contains($string1,'{sub}')))">
     <xsl:call-template name="replacebeforesubclose">
       <xsl:with-param name="stringfinal1" select="$string1"/>
     </xsl:call-template>
   </xsl:if>
</xsl:template>

<xsl:template name="replacebeforesubclose">
   <xsl:param name="stringfinal1"/>
   <xsl:call-template name="finalfirst">
     <xsl:with-param name="stringfirst" select="$stringfinal1"/>
   </xsl:call-template>
</xsl:template>



Here is the code to retrieve contents in btw these symbols '|' '\'
-------------------------------------------------------------------
<xsl:template match="content">
     <xsl:variable name="string1">
       <xsl:value-of select="substring-before(substring-after(.,'|'),'\')"/>
     </xsl:variable>
   <xsl:if test="(contains($string1,'{sub}'))">
    <xsl:call-template name="replacemidsub">
       <xsl:with-param name="string" select="$string1"/>
     </xsl:call-template>
  </xsl:if>
</xsl:template>


<xsl:template name="replacemidsub"> <xsl:param name="string"/> <xsl:if test="(contains($string,'{sub}'))"> <xsl:variable name="string1"> <xsl:value-of select="substring-before($string,'{sub}')"/> <sub> <xsl:value-of select="substring-before(substring-after($string,'{sub}'),'{/sub}')"/> </sub> <xsl:value-of select="substring-after($string,'{/sub}' )" /> </xsl:variable> <xsl:call-template name="replacemidsub"> <xsl:with-param name="string" select="$string1"/> </xsl:call-template> </xsl:if> <xsl:if test="not((contains($string,'{sub}')))"> <xsl:call-template name="replacemidsubclose"> <xsl:with-param name="stringfinal" select="$string"/> </xsl:call-template> </xsl:if> </xsl:template>

<xsl:template name=3D"replacemidsubclose">
  <xsl:param name=3D"stringfinal"/>
   <xsl:call-template name="finalmidstring">
     <xsl:with-param name="stringmid" select="$stringfinal"/>
   </xsl:call-template>
</xsl:template>


---------------------------------------------------------


code to retrieve contents after this symbol '\'
-------------------------------------------------------

<xsl:template match="content">
     <xsl:variable name="string1">
       <xsl:value-of select="substring-before(substring-after(.,'|'),'\')"/>
     </xsl:variable>
   <xsl:if test="(contains($string1,'{sub}'))">
    <xsl:call-template name="replacemidsub">
       <xsl:with-param name="string" select="$string1"/>
     </xsl:call-template>
  </xsl:if>
</xsl:template>


<xsl:template name="replacemidsub"> <xsl:param name="string"/> <xsl:if test="(contains($string,'{sub}'))"> <xsl:variable name="string1"> <xsl:value-of select="substring-before($string,'{sub}')"/> <sub> <xsl:value-of select="substring-before(substring-after($string,'{sub}'),'{/sub}')"/> </sub> <xsl:value-of select="substring-after($string,'{/sub}' )" /> </xsl:variable> <xsl:call-template name="replacemidsub"> <xsl:with-param name="string" select="$string1"/> </xsl:call-template> </xsl:if> <xsl:if test="not((contains($string,'{sub}')))"> <xsl:call-template name="replacemidsubclose"> <xsl:with-param name="stringfinal" select="$string"/> </xsl:call-template> </xsl:if> </xsl:template>

<xsl:template name="replacemidsubclose">
  <xsl:param name="stringfinal"/>
   <xsl:call-template name="finalendstring">
     <xsl:with-param name="stringend" select="$stringfinal"/>
   </xsl:call-template>
</xsl:template>


--------------------------------------------------------------


my input file looks like this.

<content>statement1 |option1\ statement2 </content>
<content>statement1 }option1\ statement2 </content>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.