Copyright © 2003 Pearson Education, Inc. Slide 4-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide to XML by Cheryl M. Hughes
Copyright © 2003 Pearson Education, Inc. Slide 4-2 CHAPTER 4 All About Style: XML Presentation
Copyright © 2003 Pearson Education, Inc. Slide 4-3 XML Presentations XML provides two methods for formatting: Cascading Style Sheets (CSS) Extensible Stylesheet Language (XSL) Benefits of separating style from content Allows authors to create elements that describe the data, not the format Allows for multiple presentation layouts for a single document Allows a single style document to format many XML documents
Copyright © 2003 Pearson Education, Inc. Slide 4-4 Cascading Style Sheets (CSS) CSS was introduced as a recommendation by the W3C in 1996 CSS is widely accepted by web browsers CSS files are plain text files and can be edited with a text editor CSS style sheets work with XML and HTML files
Copyright © 2003 Pearson Education, Inc. Slide 4-5 CSS Syntax CSS Declaration: CSS rules consists of two parts: Element selector Properties declarations CSS rule example: address { font-size: 12pt; font-family: arial } CSS comments: /* This is a comment */
Copyright © 2003 Pearson Education, Inc. Slide 4-6 CSS Properties Major property categories: Font properties Text properties Color properties Border properties Display properties
Copyright © 2003 Pearson Education, Inc. Slide 4-7 CSS Example – XML Document joe@acmeshipping.com 7 brenda@xyzcompany.com 8 02/12/01 9 Order Joe, 12Please let me know if order number has shipped. 13Thanks, 14Brenda
Copyright © 2003 Pearson Education, Inc. Slide 4-8 CSS Example – CSS File 1 to, from { 2font-weight:bold; 3text-align:left; 4border-style:solid 5} 6 date_sent { 7font-style:italic; 8color:blue 9} 10 subject { 11text-decoration:underline; 12background-color:green; 13color:yellow 14} 15 body { 16margin-top:10; 17display:block 18}
Copyright © 2003 Pearson Education, Inc. Slide 4-9 CSS Example – Viewing in Browser
Copyright © 2003 Pearson Education, Inc. Slide 4-10 Overview of XSL The XSL specification was released by the W3C in October 2001 XSL is a style sheet language developed specifically for XML XSL provides more powerful formattin features than CSS XSL behaves more like a programming language, making it very flexible