Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 23rd, 2010, 06:08 AM
Registered User
 
Join Date: Apr 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Font Color Question

Sorry for the newbie question, but I'm just starting out with XML and XSLT.

Here's the question.

I'm working on an XML transcription of a document that includes corrections written in the margins and using XSLT to display it in HTML. Here's the tag I was told to use.

Code:
<app><rdg type="corr" n="S1"> original reading </rdg><rdg type="main-corr"> correction </rdg></app>
I want to show the original reading and correction in a different color. Say, the original in blue and the correction in green.

I believe I understand how show all rdg tags in a certain color.

Code:
<xsl:template match="rdg">
	<font color="blue">
 	<xsl:apply-templates/></font>
</xsl:template>

What's throwing me is that both are rdg tags and they need to be distinguished based on the type=. I've been looking but can't figure that out. Help would be much appreciated!

Last edited by fenris ulf; April 23rd, 2010 at 06:31 AM..
 
Old April 23rd, 2010, 06:44 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Simply specify another template for the ones you want to show in a different colour:

Code:
<xsl:template match="rdg[@type='main-corr']">
...green...
</xsl:template>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old April 23rd, 2010, 07:21 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

First design your output. Do you want to control colour in your output using the HTML font element, or using CSS properties?

Once you know what output you want your XSLT to generate (in terms of XSLT elements and attributes) you can start asking about how to write the XSLT code to produce that output.

One approach would simply be to convert the "type" attributes into "class" attributes with the same value, and then to write your CSS to define the rendition of each class.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 23rd, 2010, 08:32 AM
Registered User
 
Join Date: Apr 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

@mhkay - That's a good point to keep in mind for the future. In this case, I wanted to use HTML.

@samjudson - Thanks so much, that did it! I figured it was something simple like that but I couldn't find the exact syntax. Like I said, I'm still learning





Similar Threads
Thread Thread Starter Forum Replies Last Post
not enable textbox or combobox font color SabinoFonseca VB.NET 2002/2003 Basics 1 March 15th, 2007 01:52 PM
Cell/Font Color in DataGrid. su C# 1 December 3rd, 2006 04:58 AM
how to get font ,color,font size of text in win32 satishsatao Visual C++ 0 April 5th, 2006 05:05 AM
Font Color OzzyUltra Linux 1 October 22nd, 2004 10:01 AM
font color, what different possibilites are phpsharma HTML Code Clinic 2 November 12th, 2003 06:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.