使用xslt使用基于属性值的颜色打印文本 [英] Printing text with colours based on attribute values using xslt
问题描述
亲爱的所有人,
是否可以根据属性以彩色打印内容?请分享您的想法.
例如,如果我有一个名为(change)的属性,并且如果它的值被称为省略",那么我的内容应该以红色字体打印.否则为黑色.
我在此为您提供示例文件:
<节ID ="67"更改=省略">
< Title> 67计算合伙人在公司收入中所占份额的方法</Title>
< Para>
[由1992年1月4日生效的1992年金融法删除.]
</Para>
</Section>
Dear all,
Is it possible to print contents in color based on a attribute? Please share your ideas.
Say for eg., if i have a attribute named as (change) and if its value is said to be "Omitted" then my contents should get printed in red color font. Otherwise black color.
I hereby provide you a Sample file:
<Section ID="67" Change="Omitted">
<Title>67 Method of computing a partner’s share in the income of the firm</Title>
<Para>
[Omitted by the Finance Act, 1992, with effect from 1-4-1993.]
</Para>
</Section>
推荐答案
尝试
<html>Some black text and <span style="color:red;">some red text</span>.</html>
这应该导致
一些黑色文本和一些红色文本.
This should result in
Some black text and some red text.
<xsl:choose>
<xsl:when test="@Change='Omitted'">
<span style="color:red;">red text</span>
</xsl:when>
<xsl:otherwise>black text</xsl:otherwise>
</xsl:choose>
干杯
安迪
Cheers
Andi
这篇关于使用xslt使用基于属性值的颜色打印文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!