XSL or CSS

XSL and CSS are often viewed as competing options, despite the fact that the first is a markup language and the second is a stylesheet language. However, neither is a transformation language, and XSLT or another transformation language is usually needed to create XSL documents.

Both XSL and CSS are strong candidates for styling XML documents, and at first sight they appear to compete with each other for dominance. But there is no reason why both standards should not continue to succeed, as they offer very different strengths.

Retaining self-descriptive markup

Because CSS is not a markup language, like HTML or XSL, using this standard does not involve the destruction of the self-describing markup in an XML document, and therefore permits intelligent document processing to occur after rendering. This is important because modern Web browsers are able to read XML documents into in-memory DOM tree structures (see Chapter 20), as well as apply CSS styles to display the document. Scripts can intelligently process the DOM tree after styling.

Scope and maturity

XSL attempts to do far more than CSS. It is the ideal language for formatting to paper output as it has features that control page flow and column flow, hyphenation and other features commonly found in professional paper-based output.

Conversely, CSS has been in existence far longer than XSL, and is well supported by popular Web browsers. It was initially used purely to enhance the formatting of HTML documents, but can now be equally well applied to XML documents.

Using XSLT and CSS together

CSS competes more with XSL than with XSLT. Indeed, CSS and XSLT complement each other very well, especially when the desired output format is HTML or XHMTL. XSLT can easily convert XML documents into HTML or XHTML documents that include CSS formatting instructions to improve the appearance of the resulting documents, and is equally adept at outputting in-line CSS styles, embedded stylesheets, or references to existing external CSS stylesheets.

Crossover concepts

The skills learned from using one language can be reused for using another, because XSL has adopted CSS property names and values for its attribute names and values. The colon and semicolon separators are simply replaced by an equals symbol and quotation marks around the value:

para { color:red }

<fo:block color="red">...</fo:block>

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.29.89