Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.

Similar presentations


Presentation on theme: "Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide."— Presentation transcript:

1

2 Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide to XML by Cheryl M. Hughes

3 Copyright © 2003 Pearson Education, Inc. Slide 7-2 CHAPTER 7 New XML Technologies: XSL Style Sheets and XML Schemas

4 Copyright © 2003 Pearson Education, Inc. Slide 7-3 XSL Style Sheets XSL stands for Extensible Stylesheet Language XSL, like CSS, is a language for defining format and presentation of XML documents The XSL specification was released by the W3C in October of 2001 The XSL specification contains two parts: XSL Formatting Objects (XSL-FO): an XML vocabulary for specifying formatting semantics XSL Transformations (XSLT): a language for transforming XML documents

5 Copyright © 2003 Pearson Education, Inc. Slide 7-4 XSL Formatting Objects (XSL-FO) XSL-FO is similar to CSS in that it defines formatting and presentation properties The namespace for XSL-FO is: http://www.w3.org/1999/XSL/Format XSL-FO example: 1<fo:block 2font-size=12pt 3font-color=red 4text-align=left> 5Block of text… 6

6 Copyright © 2003 Pearson Education, Inc. Slide 7-5 XSL Transformations (XSLT) XSLT is used to transform an XML document into another document format (ie – HTML or PDF) The namespace for XSLT is: http://www.w3.org/1999/XSL/Transform XSLT is currently the most widely use of XSL

7 Copyright © 2003 Pearson Education, Inc. Slide 7-6 XSLT Example: XML File 1 2 3 4 Chevy 5 Camaro 6 Blue 7 1968 8 52,000 9 $18,000 10 11 12 Ford 13 Mustang 14 Chrome 15 1965 16 12,000 17 $30,000

8 Copyright © 2003 Pearson Education, Inc. Slide 7-7 XSLT Example: XML File (cont.) 18 19 20 Jaguar 21 Roadster 22 Red 23 1967 24 76,000 25 $23,000 26 27 28 Porsche 29 911 30 1970 31 Black 32 8,000 33 $35,000 34 35

9 Copyright © 2003 Pearson Education, Inc. Slide 7-8 XSLT Example: XSL Style Sheet 1 2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 3 4 5 6 7 8 Make and Model 9 Color 10 Year 11 Mileage 12 Price 13 14 15 16 17

10 Copyright © 2003 Pearson Education, Inc. Slide 7-9 XSLT Example: XSL Style Sheet (cont.) 18 19 20 21 22 23 24 25 26 27 28

11 Copyright © 2003 Pearson Education, Inc. Slide 7-10 XML Schemas The XML Schema specification was released by the W3C in May of 2001 XML Schemas, like DTDs, are used to describe the structure of an XML document The XML Schema specification consists of two parts: XML Schema: Structures. This specification consists of a definition language for describing and constraining the content of XML documents XML Schema: Datatypes. This specification defines the datatypes to be used in XML schemas. The namespace for XML Schema is: http://www.w3.org/2001/XMLSchema

12 Copyright © 2003 Pearson Education, Inc. Slide 7-11 XML Schema Datatypes The XML Schema specification contains a number of built-in datatypes, and also allows developers to create their own datatypes Some of the built-in datatypes: Integer String Date Time

13 Copyright © 2003 Pearson Education, Inc. Slide 7-12 XML Schema Occurrence Constraints Occurrence constraints define the number of times a particular element can or must occur Attributes: minOccurs : Defines the minimum number of times an element can occur. Default value is 1 maxOccurs : Defines the maximum number of times an element can occur. Default value is 1 Can set the value of the maxOccurs attribute to unbounded to indicate that there is no maximum number of times the element can occur

14 Copyright © 2003 Pearson Education, Inc. Slide 7-13 XML Schema Simple Type Example XML file: 1 2 <email 3 xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 4 xsi:noNamespaceSchemaLocation = "email_schema.xsd"> 5This is my e-mail message 6 Schema file: 1 2 3 4

15 Copyright © 2003 Pearson Education, Inc. Slide 7-14 XML Schema Complex Type Example XML file: 1 2 <message 3 xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 4 xsi:noNamespaceSchemaLocation = "message_schema.xsd"> 5 Joe Poller 6 Brenda Lane 7 8 Order 10011 9 10Joe, 11Please let me know if order number 10011 has shipped. 12Thanks, 13Brenda 14 15

16 Copyright © 2003 Pearson Education, Inc. Slide 7-15 XML Schema Complex Type Example Schema file: 1 2 http://www.w3.org/2001/XMLSchema 3 4 5 6<xsd:element name=to type=xsd:string minOccurs-1 maxOccurs=unbounded/> 7 8 9 10 12 13 14


Download ppt "Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide."

Similar presentations


Ads by Google