Datasheet

13
Chapter 1 An Eagle’s Eye View of XML
A CSS style sheet can only change the format of a particular element, and it can
only do so on an element-wide basis. An XSLT style sheet, on the other hand, can
rearrange and reorder elements. It can hide some elements and display others.
Furthermore, it can choose the style to use based not just on the element name, but
also on the contents and attributes of the element, on the position of the element in
the document relative to other elements, and on a variety of other criteria.
XSLT is introduced in Chapter 5 and explored in detail in Chapter 15.
XSL-FO is an XML application that describes the layout of a page. It specifies where
particular text is placed on the page in relation to other items on the page. It also
assigns styles, such as italic, or fonts, such as Arial, to individual items on the page.
You can think of XSL-FO as a page description language like PostScript (minus
PostScript’s built-in, Turing-complete programming language).
XSL-FO is covered in Chapter 16.
Which style sheet language should you choose? CSS has the advantage of broader
browser support. However, XSL is far more flexible and powerful, and better suited
to XML documents. Furthermore, XML documents with XSLT style sheets can easily
be converted to HTML documents with CSS style sheets. XSL-FO is a little past the
bleeding edge, however. No browsers support it, and even third-party FO-to-PDF con-
verters such as FOP don’t support all of the current formatting object specification.
Which language you pick largely depends on your use case. If you want to serve
XML files directly to clients and use their CPU power to format and transform the
documents, you really need to be using CSS (and even then, the clients had better
have very up-to-date browsers). On the other hand, if you want to support older
browsers, you’re better off converting documents to HTML on the server using XSLT,
and sending the browsers pure HTML. For high-quality printing, you’re better off with
XSLT plus XSL-FO. An advantage of XML is that it’s quite easy to do all of this at the
same time. You can change the style sheet and even the style sheet language you
use without changing the XML documents that contain your content.
URLs and URIs
XML documents can live on the Web, just like HTML and other documents. When
they do, they are referred to by Uniform Resource Locators (URLs). For example,
at the URL
http://cafeconleche.org/examples/shakespeare/tempest.xml
you’ll find the complete text of Shakespeare’s Tempest marked up in XML.
Cross-
Reference
Cross-
Reference
03 549863 Ch01.qxd 1/28/04 9:46 AM Page 13