Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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>
Posted
Updated 3-Jul-12 0:53am
v2

1 solution

Try
XML
<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.



Now, it should be easy to write some XSLT code that creates this, e.g. use the following snippet:

XML
<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
 
Share this answer
 
v3
Comments
rahulaaditya 5-Jul-12 5:14am    
Dear Andi,
It worked :)
You did a great help sir, thanks a ton. I was breaking my head for these.

Thanks again...
Andreas Gieriet 6-Jul-12 7:28am    
You are welcome.
Andi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900