Reputation: 2493
I want to take the values if the variable I define are not equal to a particular strings. In here I want to take the values of variables 'name' , 'address' , and 'city' seperated by "-" if they are not equal to 'Tom', 'Street', and 'CityStreet' respectively. Is that possible?
xsl:attribute name='person'>
<xsl:value-of separator="-" select=
"($name, $address,
$city)" />
</xsl:attribute>
Upvotes: 1
Views: 2213
Reputation: 243599
Use:
<xsl:if test=
"not($name eq 'Tom' and $address eq 'Street' and $city eq 'CityStreet')">
<xsl:attribute name="person">
<xsl:value-of separator="-" select=
"($name[. ne 'Tom'], $address[. ne 'Street'], $city[. ne 'CityStreet'])"/>
</xsl:attribute>
</xsl:if>
Upvotes: 1
Reputation: 52888
You could use a predicate on your variables:
<xsl:attribute name='person'>
<xsl:value-of separator="-" select="($name[.!='Tom'], $address[.!='Street'],$city[.!='CityStreet'])"/>
</xsl:attribute>
or this if you don't want an empty attribute:
<xsl:if test="$name != 'Tom' and
$address != 'Street' and
$city != 'CityStreet'">
<xsl:attribute name="person">
<xsl:value-of separator="-" select="($name[.!='Tom'], $address[.!='Street'],$city[.!='CityStreet'])"/>
</xsl:attribute>
</xsl:if>
Upvotes: 1