如果我定义的变量不等于某个特定的字符串,我想要取这些值。在这里,我想获取变量'name‘、'address’和'city‘的值,如果它们分别不等于'Tom’、'Street‘和'CityStreet’,则用"-“分隔。这有可能吗?
xsl:attribute name='person'>
<xsl:value-of separator="-" select=
"($name, $address,
$city)" />
</xsl:attribute> 发布于 2012-07-04 03:46:00
你可以在你的变量上使用谓词:
<xsl:attribute name='person'>
<xsl:value-of separator="-" select="($name[.!='Tom'], $address[.!='Street'],$city[.!='CityStreet'])"/>
</xsl: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>发布于 2012-07-04 09:50:20
使用的
<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>https://stackoverflow.com/questions/11317899
复制相似问题