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

Subject: RE: [xsl] xsl:variable and creating conditional select
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 18 Mar 2003 12:43:30 +0200
> <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.

If you want the nextparent variable to contain a node that you can use in a step, it's not as simple. However, if you just want the value of the CategoryOfGroupParent attribute, then

variable nextparent
  choose
    when string-length(substring-after(., ' ')) = 0
      valua-of parent::GROUP/@CategoryOrGroupParent
    otherwise
      value-of concat(substring-after(.,' '), ' ', $ROOT)

Ah, seems that you just want a string value based on the second condition result. Hope you can read the pseudo-code above,

Cheers,

Jarno - Aiboforcen: The Shepherd's Deathline (Flesh Field remix)

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


Current Thread