Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Mimicking a SELECT/CASE statement using XSL [Thread Next] Re: Mimicking a SELECT/CASE statement using XSLTo: 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...
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
