| 
 
Subject: RE: [xsl] problem using dyn:evaluate with MSXML From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 16 Dec 2004 17:14:52 -0000  | 
> What is the recommended way to define a string-valued 
> variable computed
> by a conditional instruction?  Here's an example from a stylesheet I'm
> working on:
> 
>   <xsl:variable name="source">
>     <xsl:choose>
>       <xsl:when test="$kind >= 0 and $kind < 5000">
>         <xsl:value-of select="format-number('01','00')"/>
>       </xsl:when>
>       <xsl:when test="$kind >= 5000 and $kind < 6000">
>         <xsl:value-of select="format-number('20','00')"/>
>       </xsl:when>
>       <xsl:when test="$kind >= 6000">
>         <xsl:value-of select="format-number('30','00')"/>
>       </xsl:when>
>       <xsl:when test="$kind = 'NATO'">
>         <xsl:value-of select="format-number('40','00')"/>
>       </xsl:when>
>       <xsl:otherwise>
>         <xsl:value-of select="format-number('05','00')"/>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:variable>
In XSLT 2.0,
<xsl:variable name="x" as="xs:string" 
        select="if (X) then 'b' else 'c'"/>
In XSLT 1.0,
<xsl:variable name="temp">
  <xsl:choose>
    ....
</xsl:variable>
<xsl:variable name="x" select="string($x)"/>
> 
> Also, what is the recommended way to define an empty string-valued
> variable?
> 
>   <xsl:variable name="foo"/>
>   <xsl:variable name="foo" select="''"/>
Those are both fine.
Michael Kay
http://www.saxonica.com/
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| RE: [xsl] problem using dyn:evaluat, Michael Kay | Thread | [xsl] Counting preceding-siblings w, Jim Neff | 
| Re: [xsl] problem using dyn:evaluat, David Carlisle | Date | Re: [xsl] Sub total generation - f, David Carlisle | 
| Month |