CG0119 Web Database Systems Parsing XML: using SimpleXML & 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

Chungnam National University DataBase System Lab
Copyright © 1999, Architag International Corporation. All rights reserved. Use without express written permission from Architag International Corporation.
XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
Advanced XSLT II. Iteration in XSLT we sometimes wish to apply the same transform to a set of nodes we iterate through a node set the node set is defined.
Advanced XSLT. Branching in XSLT XSLT is functional programming –The program evaluates a function –The function transforms one structure into another.
Advanced XSLT II. Iteration in XSLT we sometimes wish to apply the same transform to a set of nodes we iterate through a node set the node set is defined.
Collections Management Museums XSLT – EMus New Page View Chris Fincham Operations Manager, North America KE Software.
WAP Next Generation
CG0119 Web Database Systems Parsing XML using SimpleXML.
 2001 Prentice Hall, Inc. All rights reserved. 1.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
4/17/2015Comp Sci 3461 XML_2 Ch. 7. 4/17/2015Comp Sci 3462 XML Vocabularies  MathML  An application to parse, render, and edit MathML: Amaya 
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
XSLT (eXtensible Stylesheet Language Transformation) 1.
XML 6.2 XSL / XSLT 6. What is XSL? XSL stands for eXtensible Stylesheet Language CSS was designed for styling HTML pages, and can be used to style XML.
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.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
XML Unit 6 October 31. XML, review XML is used to markup data Used to describe information Uses tags like HTML –But all tags are user-defined –Must be.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
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.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
XSLT XSLT: eXtensible Stylesheet Language for Transformations - a language for transforming XML documents into any text- based format (e.g. HTML, plain.
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.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
CG0119 Web Database Systems Using XPath to Navigate & Filter XML (via SimpleXML)‏
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
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,
Loading methods in PHP DOMDocument class DOMDocument extends DOMNode {... mixed load ( string $filename.
Module Road Map Credit Categories Assignment 2 Credit Category 2 You are able to demonstrate how data may be filtered using Xpath You are able to demonstrate.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
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.
The Information School at the University of Washington INFO 440: Information System Design Fall 2003 * Bob Boiko * MSIM Associate Chair XML Transforms.
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)
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.
ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method.
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.
XML Basics A brief introduction to XML in general 1XML Basics.
Jennifer Widom XML Data Introduction, Well-formed XML.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
 XSL – Extensible Style Sheet Language  XSLT – XSL Transformations › Used to transform XML documents to other formats,like HTML or other XML documents.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
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.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
Module Road Map Document Transformations Web Form (ASPX) HTML Form.
Session IV Chapter 14 – Chapter 14 – XSLThttp://
XSLT: The XML transformation language
Creating an XSLT Style Sheet for Formatting Data
Tutorial 04 (cont’) Using XPath Patterns in an XSLT Style Sheet.
XSLT 1.0.
Introduction to Internet Programming
XML Data Introduction, Well-formed XML.
More Sample XML By Sadia Anjum.
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
More XML XML schema, XPATH, XSLT
Unit 6 - XML Transformations
Presentation transcript:

CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT

XSLT EXtensible Stylesheet Language Transformations What is it? –w3c recommendation that applies style sheets to XML –Allows styles to be applied for outputting XML, to a web browser for instance. –Can also sort and filter data for output –Like CSS, separates formatting from content

Creating the XSLT (1/6)‏ <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:param name="heading" select="'XML Grade Listing (using XSLT)'"/>... Style sheet declaration (must be at the beginning of the file)‏

Creating the XSLT (2/6)‏ <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:param name="heading" select="'XML Grade Listing (using XSLT)'"/>... This is optional – purely demonstrates that parameters can be used in a similar way to variables.

Creating the XSLT (3/6)‏ <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:param name="heading" select="'XML Grade Listing (using XSLT)'"/>... Declares the output method. Can also output as “xml” and “text”.

Creating the XSLT (4/6)‏ <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:param name="heading" select="'XML Grade Listing (using XSLT)'"/>... Create a template that will be applied to any part of the XML that matches the expression. “/” is the expression for the root element.

Creating the XSLT (5/6)‏ <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:param name="heading" select="'XML Grade Listing (using XSLT)'"/>... value-of is used to extract the data from a XML element or a param. XHTML can be inserted where ever required…

Creating the XSLT (6/6)‏ <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:param name="heading" select="'XML Grade Listing (using XSLT)'"/>... Selects & applies a style for every element of a node-set as defined by the expression in the ‘select’ attribute.

Displaying XML using XSLT in PHP // Load the XML data source $xml= simplexml_load_file('grade.xml'); // one of these will work $xml= DOMDocument::loadXML(file_get_contents('grade.xml'); // Load the XML stylesheet $xsl = simplexml_load_file('grade.xsl'); // one of these will work $xsl = DOMDocument::loadXML(file_get_contents('grade.xsl'); // create an xslt processor instance $proc = new XSLTProcessor; // import the xsl stylesheet into the xslt processor $proc->importStyleSheet($xsl); // Transform and output the xml data source echo $proc->transformToXML($xml);

The output (unsorted)…

Sorting Data using the XSLT <xsl:stylesheet version="1.0" xmlns:xsl="

The output (sorted)…

Summary XSLT allows style sheets to be applied to XML documents –Separates style from content –Can output as xml, html and text Use the reference on the next page. It is a good resource

Recommended Reading - w3schools XSLT tutorial & reference