Chapter 14. XSL Formatting Objects (XSL-FO)

     

The previous chapter covered CSS; this chapter discusses XSL-FO. In distinct contrast to CSS, XSL-FO is a complete XML application for describing the precise layout of text on a page. It has elements that represent sequences of pages, blocks of text on the pages, graphics, horizontal rules, and more. Most of the time, however, you don't write XSL-FO directly. Instead, you write an XSLT stylesheet that transforms your document's native markup into XSL-FO. The application rendering the document reads the XSL-FO and displays it to the user . Since no major browsers currently support direct rendering of XSL-FO documents, there's normally a third step in which another processor transforms the XSL-FO into a readable format, such as PDF or T E X.

Once again, we demonstrate the features of XSL-FO by applying it to the simple well- formed XML document shown in Example 13-1 (in the last chapter) and repeated here in Example 14-1 for convenience.

Example 14-1. Marjorie Anderson's recipe for Southern Corn Bread
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <recipe source="Marjorie Anderson">   <dish>Southern Corn Bread</dish>   <ingredients>     <ingredient>       <quantity>1 cup</quantity>       <component>flour</component>     </ingredient>     <ingredient>       <quantity>4 tablespoons</quantity>       <component>Royal Baking Powder</component>     </ingredient>     <ingredient>       <quantity>  1  /  2  teaspoon</quantity>       <component>salt</component>     </ingredient>     <ingredient>       <quantity>1 cup</quantity>       <component>corn meal</component>     </ingredient>     <ingredient>       <quantity>1  1  /  2  cups</quantity>       <component>whole milk</component>     </ingredient>     <ingredient>       <quantity>4 tablespoons</quantity>       <component>melted butter</component>     </ingredient>   </ingredients>         <directions>     <step>Sift flour, baking powder, sugar &amp; salt together.</step>     <step>Add 1 cup corn meal.</step>     <step>       Beat egg in cup and add beaten egg and 1  1  /  2  cups whole        milk to make a batter. Stir well.     </step>     <step>       Add melted shortening and beat until light and thoroughly mixed.     </step>     <step>       Pour into greased shallow pan or greased muffin rings.     </step>     <step>       Bake in hot oven at <temperature>425  F</temperature> for       <duration>25 minutes</duration>.     </step>     <step optional="yes">       Cut into squares if cooked in shallow pan.     </step>   </directions>         <story>     After my mother-in-law <person>Marjorie Anderson</person> died,     Beth and I found this recipe written on the "extra recipes"     page in a local cookbook in her cupboard.     This was published by the The Episcopal Churchwomen,     Church of Ascension, <city>Mt. Sterling</city>,     <state>Kentucky</state>.   </story> </recipe> 



XML in a Nutshell
XML in a Nutshell, Third Edition
ISBN: 0596007647
EAN: 2147483647
Year: 2003
Pages: 232

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net