Presentation is loading. Please wait.

Presentation is loading. Please wait.

CH 5 Attributes, Empty-Element Tags, and XSL. Objective An attribute is a name-value pair included in an element’s start-tag Attributes typically hold.

Similar presentations


Presentation on theme: "CH 5 Attributes, Empty-Element Tags, and XSL. Objective An attribute is a name-value pair included in an element’s start-tag Attributes typically hold."— Presentation transcript:

1 CH 5 Attributes, Empty-Element Tags, and XSL

2 Objective An attribute is a name-value pair included in an element’s start-tag Attributes typically hold meta-information about the element rather than the element’s data XSL is a powerful style language that enables you to transform documents from one XML vocabulary to other XML vocabularies or to non- XML vocabularies such as HTML or tab-delimited text

3 The Advantages of the XML Format The data is self-describing The data can be manipulated with standard tools The data can be viewed with standard tools Different views of the same data are easy to create with style sheets

4 Attributes versus Elements Attributes can’t hold structure well Attributes are unordered. Elements are ordered Elements allow you to include meta-metadata Elements are more extensible in the face of future changes Attributes are good places to put ID numbers, URLs, and references Other information not directly or immediately relevant to the reader

5 Attributes versus Elements cont… Elements can have substructure; attributes can’t The attribute syntax is ambiguous 1.Structural – Specifies relationship between the diff element in the document 2.Semantic – related the individual elements to the real world 3.Stylistic – Specifies how an element is diplay

6 A Simple XML Element Structure Gerhard Weikum The Web in Ten Years In order to evolve... The Web provides the universal... Freely definable tags

7 Attributes versus Elements cont… <FACT SOURCE=” The Biographical History of Baseball, Donald Dewey and Nicholas Acocella (New York: Carroll & Graf Publishers, Inc. 1995) p. 169 ”> Josh Gibson is the only person in the history of baseball to hit a pitch out of Yankee Stadium. VS Donald Dewey Nicholas Acocella The Biographical History of Baseball 169 1995

8 Multiple Attribute in XML Polymerase Reactions in Organic Compounds This Above example is wrong because you can not have date attribute twice in one element

9 Multiple Elements in one XML DATE children rather than attributes allows more than one date to be associated with an element Maximum Projectile Velocity in an Augmented Railgun Elliotte Harold Bruce Bukiet William Peter 1992 10 29 1993 10 26

10 Good times to use attributes? Attributes are fully appropriate for very simple data without substructure that the reader is unlikely to want to see Appropriate for simple information about the document that has nothing to do with the content of the document Donald Dewey Nicholas Acocella The Biographical History of Baseball 169 1995

11 Empty Elements and Empty-Element Tags An element that contains no content, not even white space, is called an empty element

12 XSL Transformations XSL - This is the Extensible Stylesheet Language Divided into two parts 1. XSL Transformations (XSLT) 2. XSL Formatting Objects (XSL-FO)

13 XSL Transformations (XSLT) XSLT enables you to replace one tag with another You define rules that map your XML tags to standard HTML tags XSLT can reorder elements in the document

14 XSL Formatting Objects (XSL-FO) XSL-FO enables you to specify the appearance and layout of a page However, no web browsers yet support XSL formatting objects

15 The Transformation Process

16 XSLT Default Template An XSLT document contains one or more templates Default Templates Node TypeDefault Template RootApply templates for child nodes. ElementApply templates for child nodes. AttributeOutput attribute value. TextOutput text value. Processing InstructionDo nothing. CommentDo nothing. The default templates are shown in the table below.

17 XML Sample Paul McCartney Singer Male

18 XSLT Sample

19 Code Explanation

20 Code Explanation takes an XPath pointing to a specific element or group of elements within the XML document

21 XSLT Sample http://www.w3schools.com/xsl/xsl_intro.asp


Download ppt "CH 5 Attributes, Empty-Element Tags, and XSL. Objective An attribute is a name-value pair included in an element’s start-tag Attributes typically hold."

Similar presentations


Ads by Google