开发者

validating whether a element exists and has some specific value in xsl

how to check the tag exists and the value is 'On' do something in xsl

please correct me.,

<xsl:if test="$status and $status='On'">

 //do something

</xsl:if>

can we skip checkin开发者_C百科g whether the tag exists and direclty check for the value.

<xsl:if test="$status='On'">

     //do something

    </xsl:if>

is it a correct practice.,


<xsl:if test="$status and $status='On'">

The above is redundant, because if $status='On' then the boolean value of $status is true.

Therefore, the expression contained in the @test attribute of the above xslt instruction is equivalent to just: $status='On', which is shorter.

This completely answers the question.

It seems to me that you want to test if $status is defined and then test for its value. This is not correct -- if a reference is made to an undefined xsl:variable, this causes an error as per the W3 XSLT specification.


you should use xpath expressions

<xsl:if test="/path/node = 'On'">

</xsl:if>

or is $status a xsl param?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜