Hi
-----Mensagem original-----
De: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] Em nome de
Hesselberth, Jan
Enviada: terça-feira, 18 de Março de 2003 10:26
Para: 'XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com'
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