Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 21st, 2006, 10:53 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default another quick question

Hi, I am trying to convert an XML file into a web page using XSLT and CSS. I have successfully converted the XML information into the correct order using an XSL file and now need to change fonts, sizes etc, using the CSS file. I am having problems with making the CSS file alter the layout as I am not quite sure where I should reference the CSS file. Should it be in the XML file or the XSL file. If I put the following line of code in the <body> tag of the XSL file then it allows me to alter the font,size of <h1>, <h2>.

<link rel='stylesheet' type='text/css' href='testpage.css'></link>

I was however wanting to group the CSS statements by the nodes in the XML file so that the 'News' nodes would have one type of formatting and 'About' nodes would have another.

I see this can be done using news {} and about {} in examples, but it will not work for me.

Any help would be greatly appreciated.

p.s. I have tried putting <?xml-stylesheet type="text/css" href="testpage.css"?> after the <?xml version="1.0" encoding="utf-8"?>
line in my XML file, but it did not work.




Reply With Quote
  #2 (permalink)  
Old March 21st, 2006, 11:47 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

The XML file is transformed into an HTML document by your XSLT stylesheet; then the HTML document is displayed by the browser more-or-less exactly as if it had downloaded the HTML document directly.

So the reference to the CSS stylesheet belongs in the HTML document that you generate, not in the XSLT or in the original XML.

As for creating finer-grained references to CSS statements, I think that's an HTML question rather than an XSLT question. If you can work out how to do it in HTML, then it shouldn't be a problem to write the XSLT code to produce it. Turning that around, if you don't know what HTML you want to generate, then it's hard to write the XSLT code to produce it.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old March 21st, 2006, 12:13 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cheers Micheal,

I think I was getting confused before as I had seen a CSS file applied to an XML file directly, without any transition using an XSLT file. When I was trying to make reference to the nodes in my CSS file, the file had no knowledge about the nodes, as it was dealing with the HTML that the XSLT file had produced and not the original XML file.

Thanks for clearing that up.



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick Question! arcadium Java GUI 1 August 5th, 2008 02:16 AM
quick question treasacrowe Classic ASP Databases 2 August 30th, 2004 08:27 AM
Quick Question Ben Horne Forum and Wrox.com Feedback 1 March 22nd, 2004 03:29 PM
Quick If Then Question hcweb Classic ASP Basics 2 March 13th, 2004 02:13 PM



All times are GMT -4. The time now is 10:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.