xsl-list
[Top] [All Lists]

Re: Problem with conditional definition of a variable

2006-01-04 10:26:15
On 1/4/06, cknell(_at_)onebox(_dot_)com <cknell(_at_)onebox(_dot_)com> wrote:
Depending on whether or not a parameter is passed to the stylesheet, I'd like 
to define a variable differently.

I have defined two parameters in the stylesheet to be passed from a command 
line:

"spiral" has a default value.
"phase" is defined without a default value.

This unconditional definition works as expected:

<xsl:variable name="s1-reqs" select="document('X:/Project 
documents/matrix-xml/spiral-phase-update-template.xml')/requirements/requirement[(_at_)spiral=$spiral]"
 />

I think I ought to be able to declare the variable with a construct like this:

<xsl:variable name="s1-reqs">
  <xsl:choose>
    <xsl:when test="$phase=''">
      <!-- Something goes here when no "phase" parameter is passed -->

Whatever goes in here make the default value for $phase

    </xsl:when>
    <xsl:otherwise>
      <!-- Something goes here if a "phase" parameter is passed -->

Just use the phase parameter wherever you would use $s1-reqs, or make
$s1-reqs equal to $phase

    </xsl:otherwise>
  <xsl:choose>
</xsl:variable>

cheers
andrew

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