XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.

Slides:



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

XML I.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 12 Extensible Stylesheet Language Transformations : XSLT.
Cascading Style Sheets
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XSL XSLT and XPath 11-Apr-17.
XML: Managing Data Exchange Stylesheets. Lesson Contents CSS The basic XSL file XSL transforms Templates Sort Numbering Parameters and Variables Datatypes.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
Cascading Style Sheets Basics. Why use Cascading Style Sheets? Allows you to set up a series of rules for all pages in a site. The series may be changed.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
1/18 ITApplications XML Module Session 5: Extensible Stylesheet Language (XSL)
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
XML and XSL Transforming your XML documents with eXtensible Stylesheet Language Transformations [Optional Lecture]
ICS-FORTH 1 May 22, 2001 Christos Georgis The extensible markup language: An introduction to XML What is a XML document ? How do we check its validity.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
CM143 Week 4 Introducing CSS. Cascading Style Sheets A definition for the style in which an element of the webpage will be displayed Border width, colour,
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
SD2520 Databases using XML and JQuery
Understanding HTML Style Sheets. What is a style?  A style is a rule that defines the appearance and position of text and graphics. It may define the.
ECA 228 Internet/Intranet Design I Intro to XSL. ECA 228 Internet/Intranet Design I XSL basics W3C standards for stylesheets – CSS – XSL: Extensible Markup.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
XSLT for Data Manipulation By: April Fleming. What We Will Cover The What, Why, When, and How of XSLT What tools you will need to get started A sample.
Introduction technology XSL. 04/11/2005 Script of the presentation Introduction the XSL The XSL standard Tools for edition of codes XSL Necessary resources.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
WORKING WITH XSLT AND XPATH
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
XML About XML Things to be known Related Technologies XML DOC Structure Exploring XML.
Lecture 14 Extensible Stylesheet Language Transformations : XSLT.
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.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
IST 221 Internet Concepts and Applications Introduction to XML II CSS and XSLT Style Sheets.
CIS 375—Web App Dev II XSL. 2 XSL Introduction XSL stands for _____________________________. XSL is the language used for manipulating and displaying.
Lecture 11 XSL Transformations (part 1: Introduction)
XSLT Introduction. XSLT is the transformation part of XSL An XSLT file contains rules which are applied against and XML file to produce an output Outputs.
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
ITB Web programming for E- Commerce 1 ITB6227 Programming for E-COMMERCE Lecture Presentation of XML Documents.
1 Overview of XSL. 2 Outline We will use Roger Costello’s tutorial The purpose of this presentation is  To give a quick overview of XSL  To describe.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
1 XMLXSL(T) and CSS NOEA/PQC (rev. fen) 2007 Stylesheets CSS:Cascading Style Sheets XSL(T):eXtended Stylesheet Language (Transformations)
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
1 Lecture 7 Style Sheets: CSS. 2 Motivation HTML markup can be used to represent –Semantics: h1 means that an element is a top-level heading –Presentation:
XML Extensible Markup Language
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.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
Madam Hazwani binti Rahmat
Database Processing with XML
XML Data Introduction, Well-formed XML.
More Sample XML By Sadia Anjum.
Cascading Style Sheets™ (CSS)
More XML XML schema, XPATH, XSLT
Unit 6 - XML Transformations
Presentation transcript:

XML III

Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents

Formatting XML documents Unlike HTML, XML documents have no bearing on how they are displayed. In order to display XML documents, you must specify the display information. There are 2 approaches for achieving this: With the use of Cascading Style Sheets (CSS) With the use of Extensible Style Language (XSL) The use of CSS in formatting XML documents is quite similar to its use in formatting HTML documents. XSL, on the other hand is an evolving technology based on XML vocabulary, that is more robust than CSS. Its subset used to transform XML documents is XSLT (XSL Transformation) which can transform XML documents from one format to another.

XSLT can be used for instance to transform an XML document into an HTML document, for display purposes. In addition, because XSLT is a transformation language, you can still use CSS with it to help style the rendered output. It is important to realise that XSL and CSS are not competing technologies Rather, their usage in styling XML documents is complementary. CSS can be used to style HTML, while XSL can not; XSL can be used to transform XML documents, while CSS can not. XSL Formatting Objects technology is being designed as a superset of CSS, that will effectively replace CSS. When an XML document is transformed with XSLT, the transformation applies to the logical tree structure of the XML document, and the result is a tree of XML data.

Formatting XML documents with CSS CSS is nothing more than a formatting language, hence has the following limitations when compared to XSL: It can not take a piece of document data and reuse it elsewhere. Has no concept of sibling relationship between nodes Does not support decision structures (conditionals) It can not calculate quantities, or store values in variables. Can not be used to sort data contained in an XML document. Creating CSS for XML documents There are 2 approaches: External Style sheets and Document-level style sheets

External Style sheets are the preferred approach, as it truly separates content from presentation. This approach also facilitates using one CSS to style multiple documents. The external style sheet is basically a group of CSS style rules stored with a.css extension. The file is referenced from XML documents through the xml-stylesheet processing instruction: Within the stylesheet, the styles are defined for the required nodes of the XML document.

Example: Tony Benn 210 Temple road London NW9 0RT

Addressbook.css contact {display: block; width: 200px; border: 4px; color: blue; background-color: silver; text-align: center; } name { display: block; font-family: Times, serif; font-size: 16pt; font-weight: bold; } address { display: block; font-family:Times, serif; font-size: 14pt; } city, postcode {display: inline; font-family: Times, serif; font-size: 14pt; } phone {display: none;} Note that the contact element in the XML document does not contain any text. Hence, the style properties defined for it are passed to its child elements. The child elements in this example do have their own styles defined, and these would over-ride those defined at a higher hierarchy (the contact element), thus demonstrating the cascading effect of CSS.

XSL Extensible Style Language is a style sheet technology designed specifically for XML. Goes much further than CSS in manipulating the logical structure of XML documents. Includes high-powered programmatic constructs. Implemented in XML vocabulary, so looks like a typical XML document. Includes 2 fundamental technologies: XSL Transformation (XSLT) XSL Formatting Objects XSLT is used to transform, while XSL Formatting Objects is used to format XML documents. These technologies can be used independently or jointly.

XPath An expression language used by XSLT to address parts of an XML document. XSLT uses XPath as the basis for traversing an XML document. The syntax used by XPath is designed for use in URIs and XML attribute values, which requires it to be very concise. XPath operates under the assumption that a document has been parsed into a tree of nodes. It defines different types of nodes that are used to describe the nodes that appear within a tree. There is always a single root node that serves as the root of an XPath tree. Every element in the document has a corresponding element node. Also used in conjunction with XPointer and XLink technologies to provide advanced linking features for XML.

Creating XSL Style Sheets An XSL style sheet consists of two fundamental constructs. Templates and Patterns A template is an XSL structure that describes output to be generated on the basis of certain pattern-matching criteria. In effect, it defines a transformation structure that is applied to a certain portion of XML document. Templates are defined in XSL by using the xsl:template element It also uses an optional attribute named match to match patterns in an XML document.

The widest possible match for a document is to set the match attribute to /, which indicates that the root of the tree is to be matched..... The data in the XML document that matches the pattern in the match attribute is passed on to the template for processing.

Patterns Used in XSL templates to perform matches to the different parts of the XML document. It describes a branch of an XML tree Syntax is similar to specifying paths on a disk drive. For e.g. addressbook/contact/phone selects phone elements that appear beneath a contact element, that in turn appears beneath an addressbook element. To select an entire document tree, you use the root pattern which consists of a single forward slash (/). XSLT Template Constructs Define several constructs that control the application of templates in XSL style sheets.

xsl:value-of Element Used to insert the value of an element or attribute in the resulting output of the style. Allows you to output XML content in virtually any context, e.g between a pair of HTML tags. E.g. xsl:if Element Used to perform conditional matches in templates. Uses the match attribute as the xsl:template element. <xsl:if

xsl:for each Element Used to establish a loop for iterating through elements in a document. Contains the order-by attribute for sorting data. Its select attribute determines which elements (or attributes) are selected as part of the loops iteration. E.g.

xsl:apply-templates Element Used to apply templates that are defined in a style sheet. When an XSL processor encounters an xsl:apply templates element in a style sheet, the template corresponding to the pattern in the select attribute is applied. E.g.

Example: Tony Benn 210 Temple road London NW9 0RT

The Addressbook Style sheet Address Book Example

, Note that a template is first defined for the entire document, before individual templates are defined for each selected component of the document.