Attributes, Empty-Element Tags, and XSL

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
DOCUMENT TYPES. Digital Documents Converting documents to an electronic format will preserve those documents, but how would such a process be organized?
 2001 Prentice Hall, Inc. All rights reserved. 1.
XSL eXtensible Stylesheet Language. What is XSL? XSL is a language that allows one to describe a browser how to process an XML file. XSL can convert an.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
+ XSL eXtensible Stylesheet Language. + 2 XML Lecture Adapted from the work of Prof Mark Baker ACET, University of Reading.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
Timing in XML XML and XSL Timing framework in XML Approaches Inline syntax (SMIL) Styled Timing Timesheets Timesheets and SMIL comparison.
Rendering XML documents with XSL The most powerful approaches to rendering XML documents involve using XSL (eXtensible Stylesheet Language) XSL enables.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
XSL Unit 6 November 2. XSL –eXtensible Stylesheet Language –Basically a stylesheet for XML documents XSL has three parts: –XSLT –XPath –XSL-FO.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
Object Oriented Programming III1 XSLT Processing XML using XSLT Using XPath.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Internet Technologies1 XSLT Processing XML using XSLT Using XPath.
17 Apr 2002 XML Stylesheets Andy Clark. What Is It? Extensible Stylesheet Language (XSL) Language for document transformation – Transformation (XSLT)
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
ULI101 – XHTML Basics (Part II) What is Markup Language? XHTML vs. HTML General XHTML Rules Block Level XHTML Tags XHTML Validation.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
XSL XML Stylesheet Langauage. XPath Notation for addressing elements in an XML document /xyz - selects the root element /xyz/abc - selects all elements.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
CIS 451: XSL Dr. Ralph Westfall February, Problems With XML no formatting capabilities contra formatting tags like, etc. in HTML CSS can be used.
WORKING WITH XSLT AND XPATH
XML About XML Things to be known Related Technologies XML DOC Structure Exploring XML.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
Extensible Stylesheet Language Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University XSL-FO XSLT.
XML Part 2 Josh Steele CS 6704, Spring XML Part 2 XSL/XSLT –Structure Revisited –Definition –Example –Components XML’s Linking Languages XML’s Uses.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Lecture 11 XSL Transformations (part 1: Introduction)
XML eXtensible Markup Language. Topics  What is XML  An XML example  Why is XML important  XML introduction  XML applications  XML support CSEB.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Applying eXtensible Style Sheets (XSL) Ellen Pearlman Eileen Mullin Programming.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
 XSL – Extensible Style Sheet Language  XSLT – XSL Transformations › Used to transform XML documents to other formats,like HTML or other XML documents.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
XSLT I Robin Burke ECT 360. Outline History / Terminology XSLT processing XSLT syntax XPath XSLT basics Lab.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML Schema – XSLT Week 8 Web site:
1 XSL Transformations (XSLT). 2 XSLT XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT uses XPath.
XSLT, XML Schema, and XPath Matt McClelland. Introduction XML Schema ▫Defines the content and structure of XML data. XSLT ▫Used to transform XML documents.
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.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
CH 15 XSL Transformations 1. Objective What is XSL? Overview of XSL transformations Understanding XSL templates Computing the value of a node with xsl:value-of.
Source of website: “Text/css rel=“styles heet” This is an external style sheet link. This means that the.
In this session, you will learn to:
XSLT: The XML transformation language
XML Introduction Bill Jerome.
Unit 4 Representing Web Data: XML
Creating an XSLT Style Sheet for Formatting Data
Displaying XML Data with XSLT
eXtensible Stylesheet Language
XSLT 1.0.
Extensible Markup Language XML
Prepared for Md. Zakir Hossain Lecturer, CSE, DUET Prepared by Miton Chandra Datta
Chapter 7 Representing Web Data: XML
Applying eXtensible Style Sheets (XSL)
XML WITH CSS.
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
WHAT IS XSLT?.
Introduction to HTML5.
XSL XSLT and XPath 24-Feb-19.
XSL XSLT and XPath.
More XML XML schema, XPATH, XSLT
HTML5 and CSS3 Illustrated Unit B: Getting Started with HTML
Unit 6 - XML Transformations
Presentation transcript:

Attributes, Empty-Element Tags, and XSL 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 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

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

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

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

A Simple XML Element Structure Freely definable tags <article> <author>Gerhard Weikum</author> <title>The Web in Ten Years</title> <text> <abstract>In order to evolve...</abstract> <section number=“1” title=“Introduction”> The <index>Web</index> provides the universal... </section> </text> </article>

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. </FACT> VS <SOURCE> <AUTHOR>Donald Dewey</AUTHOR> <AUTHOR>Nicholas Acocella</AUTHOR> <BOOK> <TITLE>The Biographical History of Baseball</TITLE> <PAGES>169</PAGES> <YEAR>1995</YEAR> </BOOK> </SOURCE>

Multiple Attribute in XML <ARTICLE DATE=”06/28/1969”DATE=”06/28/1969”> Polymerase Reactions in Organic Compounds </ARTICLE> This Above example is wrong because you can not have date attribute twice in one element

Multiple Elements in one XML DATE children rather than attributes allows more than one date to be associated with an element <ARTICLE> <TITLE> Maximum Projectile Velocity in an Augmented Railgun </TITLE> <AUTHOR>Elliotte Harold</AUTHOR> <AUTHOR>Bruce Bukiet</AUTHOR> <AUTHOR>William Peter</AUTHOR> <DATE> <YEAR>1992</YEAR> <MONTH>10</MONTH> <DAY>29</DAY> </DATE> <YEAR>1993</YEAR> <DAY>26</DAY> </ARTICLE>

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 <SOURCE ID=”S1”> <AUTHOR ID=”A1”>Donald Dewey</AUTHOR> <AUTHOR ID=”A2”>Nicholas Acocella</AUTHOR> <BOOK ID=”B1”> <TITLE ID=”B2”> The Biographical History of Baseball </TITLE> <PAGES ID=”B3”>169</PAGES> <YEAR ID=”B4”>1995</YEAR> </BOOK> </SOURCE>

Empty Elements and Empty-Element Tags An element that contains no content, not even white space, is called an empty element <STATION NETWORK=”CBS” CALL_LETTERS=”WCBS”CHANNEL=”2”></STATION>

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

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

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

The Transformation Process

XSLT Default Template An XSLT document contains one or more templates The default templates are shown in the table below. Default Templates Node Type Default Template Root Apply templates for child nodes. Element Attribute Output attribute value. Text Output text value. Processing Instruction Do nothing. Comment

XML Sample <?xml version="1.0"?> <?xml-stylesheet href="beatle.xsl" type="text/xsl"?> <person> <name> <firstname>Paul</firstname> <lastname>McCartney</lastname> </name> <job>Singer</job> <gender>Male</gender> </person>

XSLT Sample <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html"/> <xsl:template match="child::person"> <html> <head> <title> <xsl:value-of select="descendant::firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="descendant::lastname" /> </title> </head> <body> </body> </html> </xsl:template> </xsl:stylesheet>

Code Explanation <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Code Explanation <xsl:value-of select="descendant::firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="descendant::lastname" /> takes an XPath pointing to a specific element or group of elements within the XML document

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