Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using xsl when to test for attribute values

Tags:

xml

xslt

Am using <xsl:when> in my code.I need to test values for 2 different attributes in the "when" condition below i.e.(<xsl:when test="??">) How do i do that please?

I tried this,but it does not work:

<xsl:when test="@Attrb1[.!=''] and @Attrb2[.!='']">

Also, this gives an error too:

<xsl:when test="@Attrb1 !='' and @Attrb2 !=''"> 

msxml3.dll error '80004005'

error '80004005'
Expected token 'eof' found '!='. @Attrb -->!=<--'' and @Attrb2 !=''

Code:

<xsl:when test="Condition1"> 
<xsl:choose> 
    <xsl:when test="??"> 
         <xsl:value-of select="somtext1"/> </xsl:when> 
    <xsl:otherwise> 
          <xsl:value-of select="somtext2"/> 
</xsl:otherwise> 
</xsl:choose>
</xsl:when>

Thanks.

like image 521
livehed Avatar asked Jun 01 '26 02:06

livehed


2 Answers

Use instead:

<xsl:when test="@Attrb2!='' and @Attrb2!=''">
like image 94
Jim Garrison Avatar answered Jun 02 '26 21:06

Jim Garrison


Or use:

<xsl:when test="not(@Attrb1='') and not(@Attrb2='')">
like image 31
Daniel Haley Avatar answered Jun 02 '26 19:06

Daniel Haley