Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Mimicking a SELECT/CASE statement using XSL

From: ptjm@--------.--- (------- -- ------)
To: NULL
Date: 5/4/2004 1:48:00 AM
In article <ffa5071b.0405030927.1c089691@p...>,
Gadrin77 <gadrin7@a...> wrote:

% as a newbie to XSL, is it possible to mimic a SELECT/CASE statement
% using
% XSL?

Yes.

% I tried a quickie and I kept getting errors either using PARAM or
% WITH-PARAM
% in the wrong place or VARIABLE.

With is nothing to do with the former question. Yes, there's something
like a select (xsl:choose), and no, it doesn't change the scoping
rules for variables.

 <xsl:variable name='xsl-var1'>
    <xsl:choose>
       <xsl:when test='$class = 1'><xsl:text>10</xsl:text></xsl:if>
       <xsl:otherwise><xsl:text>20</xsl:text></xsl:if>
    </xsl:choose>
 </xsl:variable name='xsl-var1'>

% I'm not sure the value of a XSL:VARIABLE can be redefined.

It can't be. You can get the same effect using parameters and
recursive template calls. You could also use recursive calls to
solve your initial problem.

    <xsl:choose>
       <xsl:when test='$class = 1'>
          <xsl:call-template name='guts'>
             <xsl:with-param name='xsl-var1' select='10'/>
             <xsl:with-param name='xsl-var2' select='11'/>
          </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
          <xsl:call-template name='guts'>
             <xsl:with-param name='xsl-var1' select='20'/>
             <xsl:with-param name='xsl-var2' select='21'/>
          </xsl:call-template>
       <'xsl:otherwise>
    </xsl:choose>

then you'd use the parameters in a template called guts.
-- 

Patrick TJ McPhee
East York  Canada
ptjm@i...


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