xsl-list
[Top] [All Lists]

RE: Conditional with-param

2004-05-23 07:24:22
Hi Marco,

Without understanding exactly what it is you are trying to accomplish
the easiest way to solve your particular dilemma is to create a variable
outside of the xsl:apply-templates element that uses conditional logic
to determines its value.  Also, to ensure that you only get one matching
value I would use an xsl:choose block to determine the value of the
variable.  For example:

<xsl:variable name="foo">
  <xsl:choose>
    <xsl:when test="condition1">
      ...value if condition1 is true
    </xsl:when>
    <xsl:otherwise>
      ...value if condition1 is not true
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>
  
<xsl:apply-templates select="/foo/bar">
  <xsl:with-param name="foo" select="$foo"/>
</xsl:apply-templates>

Within your matching template you would need to create a parameter
called 'foo' that would hold the value passed to it using xsl:with-param
and having the same name.

Hope this helps!

<M:D/>

-----Original Message-----
From: Marco [mailto:brbromo(_at_)tin(_dot_)it]
Sent: Thursday, May 20, 2004 7:35 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Conditional with-param

Is it possible to do something like

<xsl:apply-templates>
  <xsl:if select="condition1">
   <xsl:with-param name="myparam1">
  </xsl:if>
  <xsl:if select="condition2">
   <xsl:with-param name="myparam2">
  </xsl:if>
</xsl:apply-templates>

or should I write a four-cases choose instruction, with four different
options combinations?

Marco



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



<Prev in Thread] Current Thread [Next in Thread>