A Simple Stylesheet

   



The XML File book.xml

The file book.xml is an XML document that will be used in a number of examples involving XSL stylesheets, and its contents are shown in Listing A.2.

Listing A.2 book.xml

start example
<book>   <author>Oswald Campesato</author>   <title>SVG Programming</title>   <desc>A book about SVG and Java</desc>   <chapters>     <chapter>      <number>1</number>      <desc>sine waves and gradients</desc>      <length>25</length>     </chapter>     <chapter>      <number>2</number>      <desc>sine-based SVG and animation</desc>      <length>35</length>     </chapter>     <chapter>      <number>3</number>      <desc>polynomials and rational functions</desc>      <length>40</length>     </chapter>   </chapters>   <appendices>     <appendix>      <title>XSL Basics</title>      <desc>An Overview of XSL</desc>      <length>25</length>     </appendix>   </appendices> </book>
end example

Some of the questions you might ask about the information in this XML document are listed below:

  1. What are the title and author of the book?

  2. How many chapters are there? What are their titles?

  3. What are the descriptions of the available appendices?

  4. Which chapter is the shortest? The longest?

All of the preceding questions can be answered (in some cases with surprising ease) by applying an XSL stylesheet to the XML document. Before we look at some examples, notice that the <title> and <desc> tags appear in multiple locations, and hence their interpretation is context-dependent; that is, you need to differentiate between a <title> tag for the book and a <title> tag for a chapter (similarly for the <desc> tag).



   



Fundamentals of SVG Programming. Concepts to Source Code
Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)
ISBN: 1584502983
EAN: 2147483647
Year: 2003
Pages: 362

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