RE: [xsl] xsl:variable and creating conditional select

Subject: RE: [xsl] xsl:variable and creating conditional select
From: Américo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Tue, 18 Mar 2003 11:05:47 -0000
Hi

> -----Mensagem original-----
> De: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] Em nome de 
> Hesselberth, Jan
> Enviada: terça-feira, 18 de Março de 2003 10:26
> Para: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Assunto: [xsl] xsl:variable and creating conditional select
> 
> 
> Hi everyone,
> I have the following logical requirement
> 
> <xsl:if test= "substring-after(.,' ')=''">
>         	<xsl:variable name="nextparent" 
> select="parent::GROUP/@CategoryOrGroupParent"/>
> </xsl:if>
> <xsl:if test= "substring-after(.,' ')!=''">
> 	 <xsl:variable name="nextparent" 
> select="concat(substring-after(.,'
> '),' ',$ROOT)"/>
> </xsl:if>
> 
> I know this won't work as the variables go out of scope. 
> However, I can't figure out how to set the expression in the 
> select of the xsl:variable to give me the required results. 
> Any help would be greatly appreciated. Cheers
> 	Jan
> 
> 

You'll have to think upsidedown (don't know if this is the right word
for this, but...), i.e., istead of setting the variable inside the
condition, do the test inside the variable.

<xsl:variable name="nextparent">
 <xsl:choose>
  <xsl:when test="substring-after(.,' ')=''">
  <xsl:value-of select="parent::GROUP/@CategoryOrGroupParent"/>
  </xsl:when>
  <xsl:otherwise>
  <xsl:value-of select="concat(substring-after(.,' '),' ',$ROOT)"/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:variable>

Hope this helps


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread