الاثنين، 19 يناير 2009

The Difference Between CSS and XSLT

The Difference Between CSS and XSLT
They're Both Style Sheets, Right? YES
Many people believe that CSS is for HTML and XSL or XSLT is for XML, but that's not strictly true. While both are style sheets, they serve two vastly different purposes

The reason is that CSS is much easier to use, easier to learn, thus easier to maintain and cheaper. There are WYSIWYG editors for CSS and in general there are more tools for CSS than for XSL. But CSS's simplicity means it has its limitations. Some things you cannot do with CSS, or with CSS alone. Then you need XSL, or at least the transformation part of XSL

What CSS Can Do
  • Modify the font size, color, family, and style of text in markup
  • Define the location and size of an element
  • Change the background image and color of elements
  • Create a new look and feel for markup pages to display on the Web

What CSS Cannot Do

  • Change the order of elements in a document
  • Make computations based on the content of the document
  • Add content to the document
  • Combine multiple documents into one

What XSLT Can Do

  • convert data in a standard XML format to SQL statements, tab-delimited text files, or other database formats for data sharing
  • transform XSLT style sheets into new style sheets
  • turn Web pages (written in XHTML) to VoiceML or XHTML Basic for handheld devices
  • add CSS style sheets to XML documents for view in a browser

If all you're looking for is a style sheet to manipulate the way your content looks in a document, then you should use CSS. But if you're looking to actually transform one document into another, then XSLT is your tool


Diagram of the role of XSL and CSS in rendering HTML and  XML documents

This diagram shows the role of XSL and CSS. XML documents can be rendered in three different ways: (1) if the document doesn't have to be transformed, use CSS. Otherwise, use XSL-T, the transformation language of XSL, in one of two ways: either (2)generate the style properties together with the rearranged text, using a sub-language of XSL called XSL-FO (XSL Formatting Objects); or (3) generate a new XML or HTML document and provide a CSS style sheet for that new document.

source

0 التعليقات: