xsl-list
[Top] [All Lists]

RE: RE: get variable value in another template

2005-12-28 05:34:11
It's not entirely clear what problem you are describing, so I'll make a few 
remarks about the scope of variables in XML and ask you for a clarification.

A variable defined in a template has the scope of the template. That is to say, 
if you define a variable in template A, you cannot access it from template B 
unless you pass the variable as a parameter to template B.

If you can take the trouble to explain which specific variable (the name of the 
variable will be sufficient identification) you can't access from which 
template (perhaps here you can quote the line in the template as well as giving 
its name), then you will most likely get the help you need.

As your question is currently constructed, it's nearly impossible to determine 
what question you are asking.
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     T Uma Shankari 
<umashankari(_at_)lantana(_dot_)tenet(_dot_)res(_dot_)in>
Sent:     Wed, 28 Dec 2005 08:39:13 +0530 (IST)
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  RE: [xsl] get variable value in another template


No, I didn't.

On Tue, 27 Dec 2005 cknell(_at_)onebox(_dot_)com wrote:

Did you get an answer to this?
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     T Uma Shankari 
<umashankari(_at_)lantana(_dot_)tenet(_dot_)res(_dot_)in>
Sent:     Mon, 26 Dec 2005 16:34:07 +0530 (IST)
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl] get variable value in another template


Hello all,

  I have assigned a value to variable in one template. While accessing the
same variable from another template, i couldn't retrieve that variable
value. I tried it a different method but i couldn't get the value. here is
my code

Actually i need  to replace {sub} tag to <sub> and {/sub} to </sub>

<xsl:template name="globalsubReplace">
  <xsl:param name="outputString"/>
  <xsl:param name="target"/>
  <xsl:param name="replacement"/>
   <xsl:variable name="outputString12">
  <xsl:choose>
    <xsl:when test="contains($outputString,$target)">
      <xsl:value-of 
select="concat(substring-before($outputString,$target),$replacement)"/>
      <xsl:call-template name="globalsubReplace">
        <xsl:with-param name="outputString" 
select="substring-after($outputString,$target)"/>
        <xsl:with-param name="target" select="$target"/>
        <xsl:with-param name="replacement" select="$replacement"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$outputString"/>
    </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
<!--  <xsl:value-of select="$outputString12"/>-->
</xsl:template>



<xsl:template name="globalsubclose">
<xsl:param name="outputString12"/>
  <xsl:param name="target1"/>
  <xsl:param name="replacement1"/>
 <xsl:value-of select="$outputString12"/>
 <xsl:variable name="outputString22">
  <xsl:choose>
    <xsl:when test="contains($outputString12,$target1)">
      <xsl:value-of
select="concat(substring-before($outputString12,$target1),$replacement1)"/>
      <xsl:call-template name="globalsubclose">
        <xsl:with-param name="outputString1" 
select="substring-after($outputString12,$target1)"/>
        <xsl:with-param name="target1" select="$target1"/>
        <xsl:with-param name="replacement1" select="$replacement1"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="$outputString12"/>
    </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
</xsl:template>


<xsl:template match="opt">
<xsl:call-template name="globalsubReplace">
  <xsl:with-param name="outputString" select="."/>
  <xsl:with-param name="target" select="'{sub}'"/>
  <xsl:with-param name="replacement" select="'<sub>'"/>
  </xsl:call-template>
 <xsl:call-template name="globalsubclose">
  <xsl:with-param name="outputString12" select="."/>
  <xsl:with-param name="target1" select="'{/sub}'"/>
  <xsl:with-param name="replacement1" select="'</sub>'"/>
  </xsl:call-template>
</xsl:template>


can anyone please tell me the solution for this?

thanks in advance
uma







--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--


--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--