开发者

How do I use XSL:if with classes?

开发者 https://www.devze.com 2023-03-06 01:51 出处:网络
Here\'s a basic example of what I\'d like to do today: IF CLASS=.TEST Show THIS content I\'m not to clear on all of the variables I can place within: < xsl:if 开发者_C百科test=\"{HERE}\" >

Here's a basic example of what I'd like to do today:

IF CLASS=.TEST Show THIS content

I'm not to clear on all of the variables I can place within: < xsl:if 开发者_C百科test="{HERE}" >

*Note: I can manipulate the content by using Boolean: < xsl:if test="price>2" > but mathematical equations won't really help me for what I'm trying to accomplish.


It looks like you need to check our w3schools here: http://www.w3schools.com/Xsl/el_if.asp.

In your scenario you might be better with

<xsl:choose>
    <xsl:when test="test1">output1</xsl:when>
    <xsl:when test="test2">output2</xsl:when>
    ...
    <xsl:otherwise>some error or other</xsl:otherwise>
</xsl:choose>


In many cases you don't need to use a conditional XSLT instruction such as <xsl:if>.

It is better to use pattern matching:

<xsl:template match="*[@class='someValue']">
  <!-- Necessary processing here -->
</xsl:template>
0

精彩评论

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