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 March 21st, 2006, 10:53 AM
Registered User
 
Join Date: Mar 2006
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.




 
Old March 21st, 2006, 11:47 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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
 
Old March 21st, 2006, 12:13 PM
Registered User
 
Join Date: Mar 2006
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.








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





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