Southend Linux User Group

CSS and XSL

Comparison of CSS and XSL

The fact that W3C has developed XSL in addition to CSS has caused some confusion. Why develop a second style sheet language. The table below provides a simple comparison. The single most important difference between the two is XSL transformation abilities. If though you simply want to be able to style an XML document, then CSS will probaly be your preferred choice, especially if you already have experience of using it.

CSS XSL
Can be used with HTML? yes no
Can be used with XML? yes yes
Transformation language? no yes
Syntax CSS XML

The unique features are that CSS can be used to style HTML and XML documents. XSL, on the other hand, is able to transform documents. This is at the core of XSL. For example, XSLT can be used to transform XML data into XHTML/CSS documents on the Web server. This way, the two languages complement each other and can be used together. The transformation process takes an XML input file (or source-tree) and tranforms it into an XML/XHTML output file (or result-tree).
XSLT can add/remove elements and attributes to the output file, as well as rearrange and sort elements, Decisions about which elements to hide and display can also be taken. This makes it a logical choice over CSS when taking raw information from a database, and converting into an XHTM web page.

Both languages can be used to style XML documents.

CSS and XSL use the same underlying formatting model and designers therefore have access to the same formatting features in both languages. W3C will work hard to ensure that interoperable implementations of the formatting model are available.

Author: Alan Campion - Page reference: 932
Last modified: Alan Campion - 2014-10-18