Jump to content

XSLT and CSS


walkingbeard

Recommended Posts

I've been reading about CSS for a long, long time now and I've been hearing about XSL for almost as long, but I still can't quite work XSL out, regarding its purpose. It seems to me that half of the function of XSL is embodied in XSL-FO, which doesn't seem to be a part of the browser like XSLT is.People are always saying that CSS is dying and XSL is the way forward, but I can't find any tutorials on how to change fonts, or position stuff with XSLT, without resorting to including a CSS in the output, or using old HTML attributes like fname and width. Can someone please explain how XSLT replaces CSS?I also read another newbie thread here and the person who replied reckoned that you shouldn't embed a link to XSLT or XSL-FO styles in your XML data file. How are you supposed to format the data then?

Link to comment
Share on other sites

XSL is a stylesheet for XML element. This means you tell how or what to do with the elements. Like HTML does automaticly. CSS is used for the design of your text and positioning of items. You can also do this within XSL but that gives you an messy code. Just like in HTML, you can say font, size etc. But when you do this with CSS you have a clean HTML / XSL code. The advantage of this is the overvieuw in your code, this means youre code is easilly to edit.Don't think CSS going to dissapear soon. CSS is just a smaller part of the whole system. But still useble.The best way in my eyes is use XSL for the translation of the XML elements and do as mutch as possible design in CSS.

Link to comment
Share on other sites

The best way in my eyes is use XSL for the translation of the XML elements and do as mutch as possible design in CSS.

Agree.What you have understood wrong is probably the difference between XSLT and XSL-FO. XSL-FO contains many formatting stuff which could possibly replace CSS styling, but it's certanly not going to because of it's usability issues. XSL-FO makes it hard to acomplish things which are easy with CSS and yet it doesn't provide anything that CSS hasn't got. Because of that reason XSL-FO's place in the world wide web remains the one place where CSS is still a bit weak: Technical reports, papers and other off-screen media.XSLT on the other hand is practically the other part of XMLs mission- To separate content from presentation. It's also THE language for transforming one XML based language to any other XML based language (not necessary XHTML!!).The most typical situation which can illustrate XSLTs usefullness would be a plain XML file containg a content of a single page of yours. By using XSLT, you can turn that content into XHTML and add all common data (shared across pages) by processing another XML document and adding it's data into the page. The result is A LOT easier maintainance for you.However, using only one XHTML doesn't mean you have to spoil it by adding visual data. Infact it's bad. CSS could be used to serve different devices all of which read XHTML. XSLT allows you to share one content with different formats (beyond XHTML... like WML or SVG for starters) while CSS allows you to add different visualizations to the XHTML only.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...