Lecture 15 Extensible Stylesheet Language Transformations : XSLT.

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

Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
Multimedia Seminar XSLT Tobias Naumann. MM Seminar - XSLT2 Structure What is XSLT? Design and Concepts Practical use Examples.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 12 Extensible Stylesheet Language Transformations : XSLT.
XSLT 11-Apr-17.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
UFCEKG-20-2 Data, Schemas & Applications Lecture 5 XML & PHP.
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.
+ XSL eXtensible Stylesheet Language. + 2 XML Lecture Adapted from the work of Prof Mark Baker ACET, University of Reading.
Transforming XML Part I Document Navigation with XPath John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
XML and XSL Transforming your XML documents with eXtensible Stylesheet Language Transformations [Optional Lecture]
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
Rendering XML documents with XSL The most powerful approaches to rendering XML documents involve using XSL (eXtensible Stylesheet Language) XSL enables.
Lecture 14 XML Validation. a simple element containing text attribute; attributes provide additional information about an element and consist of a name.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
Lecture 12. Default Processing in XSLT The default processing in XSLT is to process the XPath root node The default processing for various node types.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
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.
Technical Track Session XML Techie Tools Tim Bornholt.
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.
Lecture 15 XML Validation. a simple element containing text attribute; attributes provide additional information about an element and consist of a name.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
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.
XML and its applications: 4. Processing XML using PHP.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
XSLT and XPath, by Dr. Khalil1 XSL, XSLT and XPath Dr. Awad Khalil Computer Science Department AUC.
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
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.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Lecture 2 : Understanding the Document Object Model (DOM) UFCFR Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
Sheet 1XML Technology in E-Commerce 2001Lecture 7 XML Technology in E-Commerce Lecture 7 XSL Formatting Objects, Java Data Binding.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
Advanced Java Session 9 New York University School of Continuing and Professional Studies.
Lecture 14 Extensible Stylesheet Language Transformations : XSLT.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
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 "
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
Lecture 11 XSL Transformations (part 1: Introduction)
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 – XSL: Extensible Stylesheet Language Transformations (XSLT) Outline 12.1Introduction 12.2Setup.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Applying eXtensible Style Sheets (XSL) Ellen Pearlman Eileen Mullin Programming.
ITB Web programming for E- Commerce 1 ITB6227 Programming for E-COMMERCE Lecture Presentation of XML Documents.
Lecture 3 : PHP5-DOM API UFCFR Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong.
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.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
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.
Martin Kruliš by Martin Kruliš (v1.1)1.
XML Validation. a simple element containing text attribute; attributes provide additional information about an element and consist of a name value pair;
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
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.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
Unit 4 Representing Web Data: XML
XML in Web Technologies
Chapter 7 Representing Web Data: XML
XML and its applications: 4. Processing XML using PHP
Unit 6 - XML Transformations
Presentation transcript:

Lecture 15 Extensible Stylesheet Language Transformations : XSLT

Example (well-formed) XML document (Lec. 13) Joseph Michael Bloggs Joe Mr 2 Gloucester Road Bristol Avon BS2 4QS repeating “street element.

Example document with validation (Lec. 14) Joseph Michael Bloggs Joe Mr 2 Gloucester Road Bristol Avon BS2 4QS <xs:schema elementFormDefault="qualified“ attributeFormDefault="unqualified“ xmlns:xs=" patient.xml patient.xsd “patient.xml” is now an instance document in the vocabulary defined in the schema “patient.xsd”

XSLT XSLT – Extensible Stylesheet Language Transformations is an application for specifying rules which transform one XML document into another document. It uses template rules in the stylesheet to match patterns in the input document and when a match is found it writes the template from the rule to the output tree. Basic XSLT processing model

XSLT Document Model (showing parser) xpath engine

XSLT Parser Processing Model Both the source document and XSLT stylesheet are loaded into the processor's memory. How this happens is dependent on the implementation. One option is that both are loaded as DOM documents under the control of a program. Another option is that the stylesheet is referenced by a processing instruction in the source XML document. IE5/6 or Netscape6 can load the stylesheet when the XML document is loaded.

XSLT is a functional “4gl programming” language A function maps one set of “things” onto another set of “things” using one or more rules. simple function: x 2 = ysimple xslt “function” or “template” rule ‘ x y when this pattern found in the input document Reuben output this Hello Reuben Hello OUTPUT

XSLT uses “XPath” to find nodes in a xml document Joseph Michael Bloggs Joe Example 1: ……………. do something with content xslt rule using xpath expression – match the element Example 2: : xslt rule using xpath expressions (2) – get the value of the attribute named “nhs-no” in the element.

patient name title address fax tel first middle last previous preferred street1 street2 street3 city county postcode home mobile JosephMichaelBloggs Joe 2 Gloucester Rd BristolAvon BS2 4QS Mr nhs-no KEY element content attribute the tree view of example xml document xpath is simply a way of finding specific nodes in a document tree – like files in a file hierarchy – e.g. “c:\teaching\myfiles\thisdoc.doc”.

xpath axes (node sets) xpath has thirteen axis child parent decendent ancestor descendent-of-self ancestor-of-self following-sibling preceding-sibling following preceding attribute namespace self

xslt & push and pull models of document processing push model - source document controls the structure – e.g cascading style sheet (CSS) – applies a style but cannot change the structure of the input document. pull model – the stylesheet controls the structure and the source documents acts as the data source. xslt can apply both the push and pull model - you can write a xslt stylesheet to change the order of elements, do calculations based on the number of elements (using xpath), do branching depending on an element value, generate other stylesheets, write java or c# code or source code for any other language, use svg to generate graphics, apply formatting object (fo) constructs that tell a fo-processor to lay out pages for printing or write pdf and almost everything else supported by other programming languages. hence it has all the constructs to apply our fundamental ‘Jackson’ concepts of sequence, selection and iteration.

XSLT parser processing API’s and the push/pull models Tree Based – these parsers read the source and style documents and build a tree in memory of all nodes. Often some indexing mechanism will be applied. The trees can then be processed in any order since all nodes are available once the tree has been built. Examples include the Document Object Model (DOM) based API’s such as that used in Apache Xerces DOM API.Document Object Model (DOM) Apache Xerces Distadvantages of tree based API models is that because they often load the entire XML document into memory – they can require an awful lot of memory. Sometimes a hundred times as much as the document itself. This makes this model unwieldy for very large documents. Push Model – or the producer/consumer model. These parsers control the pace of the application by parsing the producer (the xml source doc) and informing the consumer (the application program) when certain events occur. The classic example is the SAX (Simple Model for XML) API. The best known SAX implementation is Apache Xerces SAX API.SAXApache Xerces Advantages include the fact that the whole document need not exist in memory all at once. But jumping to various places in the document is hard and must be handled by the programmer. Pull Model - the API requests events from the producer (xml source doc) rather than waiting for these events to occur. A notable pull model parser is found in the XMLReader class in the.NET framework. Typically a loop is created that continually reads from the xml document until the end but acts on open items as they are seen.XMLReader Curser Model - the newest class of xml parsing API. The cursor acts as a lens on the source document but unlike push/pull models the cursor can jump to anywhere in the document. Thus it has all the advantages of the tree based model but without the massive memory overhead. The ObjectXpathNavigator class in the.NET frameowrk implements a cursor based API. ObjectXpathNavigator

Joseph Michael Bloggs Joe Mr 2 Gloucester Road Bristol Avon BS2 4QS stylesheet “patiemt.xslt” used to generate HTML example xslt stylesheet “patient.xslt” (1)

example xslt stylesheet (2) minimum stylesheet: the xslt parser (msxml) that “built into” internet explorer applies the above stylesheet

xslt stylesheet fragment : from “patient.xslt” (3) fragment 1 Patient Record XSL Transformation Example Patient Record <table border="1" cellpadding="4" cellspacing="0" bordercolor="#cccccc" width="400"> NHS Number start the template end the template output a table output 1 row with two columns -write “NHS Number” in first column - write the value of the attrubute in the second column apply all other templates output: Patient Record XSL Transformation Example Patient Record <table border="1" cellpadding="4" cellspacing="0" bordercolor="#cccccc" width="400"> NHS Number [RESULT FROM APPLYING ALL OTHER TEMPLATES]

xslt stylesheet fragment : from “patient.xslt” (4) fragment 2 – make a selection Fax - test if the context node (“self”) is empty if it is write “-” otherwise output the content string of the context node; represented by “.” mailto: fragment 3– output a html hyperlink output

example xslt stylesheet : from “patient.xslt” (5) fragment 4 – do a while loop (iteration) cycle through all the “street” nodes and if not empty then output any content full version of the “patient.xslt” file can be found with the other example files “patient.xml” now points to it ( notice how Internet Explorer applies the stylesheet )