开发者

Display XSLT variable in different colors depending on condition

开发者 https://www.devze.com 2023-03-13 05:40 出处:网络
I have an xslt file. In this file, I have an xsl choose statement. When certain conditions occur (for example, when the variable is either positive or negative), I want to display that xsl variable in

I have an xslt file. In this file, I have an xsl choose statement. When certain conditions occur (for example, when the variable is either positive or negative), I want to display that xsl variable in a different color. I know how to set up the choose statement - my problem is being able to set the color to display it in. I've been told to use a JQuery .addClass() function, but I have no idea how to do this. Any information at how to do this, and if I need to import anything into my file to do so would be great. thanks!开发者_JAVA技巧


Note that CSS can be used to style an XML document, there is no need to use jQuery here (in my opinion).

Here is how I would approach the problem. When your XSLT produces elements based on choose, simply assign an attribute class and a value positive or negative) to the element that you output (number), so you have the output like:

<number class="positive">5</number>
<number class="negative">-5</number>

The CSS selector can then look like:

number.positive { color: blue; }
number.negative { color: red; }
0

精彩评论

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