XML Data Management XSLT Exercises: Right or Wrong? Werner Nutt.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
XML Data Management 8. XQuery Werner Nutt. Requirements for an XML Query Language David Maier, W3C XML Query Requirements: Closedness: output must be.
College of Information Technology & Design
CAR Training Module PRODUCT REGISTRATION and MANAGEMENT Module 8-Supersede an Existing CAR Document (Run as a PowerPoint show)
Extensible Stylesheet Language for Transformations XSLT An introduction.
XML: Managing Data Exchange Stylesheets. Lesson Contents CSS The basic XSL file XSL transforms Templates Sort Numbering Parameters and Variables Datatypes.
Introduction to XSLT. What is XML? Design Goals of XML XML Format XML Declaration ElementsAttributes.
Lecture 16. the xsl:variable element The format of the xsl:variable element is or or It tells the XSLT processor to –instantiate the variable with the.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
XSL Transformations (XSLT) Meghasyam Bokam April’1 st, 2002.
Recycled from Gill Windall’s notes
1 CSE Students: Please do not log in yet. Check-in with Brian in the back. Review Days 3 and 4 in the book. Others: Please save your work and logout.
XSL Unit 6 November 2. XSL –eXtensible Stylesheet Language –Basically a stylesheet for XML documents XSL has three parts: –XSLT –XPath –XSL-FO.
Lecture 15. Repetition In essence, repetition is already built into the default processing provided by every XSLT processor –the default processing for.
XSLT programming examples Jaana Holvikivi Metropolia.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
XML - XSLT © 2012 t he University of Greenwich 1 XML Processing with XSLT Kevin McManus
Selection Sort
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.
SD2520 Databases using XML and JQuery
More on XSLT. More on XSLT variables Earlier we saw two ways to associate a value with a variable  A variable whose value is the empty string, for example.
XSLT Part 3B. id() The id() function returns a node-set containing the node or nodes with a given ID attribute. An ID attribute in this context is any.
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.
CIS 451: XSL Dr. Ralph Westfall February, Problems With XML no formatting capabilities contra formatting tags like, etc. in HTML CSS can be used.
Session II Chapter 2 – Chapter 2 – XSLhttp://
1 XML Data Management 7. XLST Werner Nutt. Kernow and Saxon To demo XSLT, we use Kernow –Kernow is a (graphical) front end for Saxon Saxon is an XSLT,
Transforming XML Part II XML Document Transformation with XSLT John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
XML Court Forms Harry Jacobs Judicial Council of California – Administrative Office of the Courts
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
The Information School at the University of Washington INFO 440: Information System Design Fall 2003 * Bob Boiko * MSIM Associate Chair XML Transforms.
XSLT Aug ’10 – Dec ‘10. Aug’10 – Dec ’10 1 XSLT  Extensible Stylesheet Language Transformation  Declarative programming language written in XML to convert.
CSE 428 Semantic Web Topics XML Jeff Heflin Lehigh University.
 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.
XSL and XSLT 06. XSL and XSLT © Aptech Limited Introduction to XSL  In this first lesson, Introduction to XSL, you will learn to:  Define XSL, XSLT,
XML XSLT Variables & parameters Feb 20, Variables ● More like an algebraic variable than a programming variable ● Think of it as similar to a constant.
1 XML Data Management Extracting Data from XML: XPath Werner Nutt based on slides by Sara Cohen, Jerusalem.
Selection Sort
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
XML Data Management XPath Exercises: Right or Wrong? Werner Nutt.
XPath. XPath, the XML Path Language, is a query language for selecting nodes from an XML document. The XPath language is based on a tree representation.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
1 XML Data Management XLST Werner Nutt. A Hello World! Stylesheet world.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Factorization : Difference of Two Squares and Perfect Squares.
XML Data Management XPath Exercises: Right or Wrong? Werner Nutt.
Exam 2 Review. SQL – Create Table REMEMBER!! – Create table mxws.Contact ( ContactID INT(10) NOT NULL,.., primary key (contactID));
CITA 330 Section 5 XPath. XSL XSL (Extensible Stylesheet Language) is the standard language for writing stylesheets to transform XML documents among different.
XML Schema – XSLT Week 8 Web site:
XML - XSLT © 2015 University of Greenwich 1 XML Processing with XSLT e Xtensible Stylesheet Language Transforms Dr Kevin McManus
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.
Incomplete Answers over Semistructured Data Kanza, Nutt, Sagiv PODS 1999 Slides by Yaron Kanza.
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
Digital Media Technology
XSLT: The XML transformation language
C++ Memory Management – Homework Exercises
Applying eXtensible Style Sheets (XSL)
XML WITH CSS.
Using Matrices with Transformations
Primary Claims/Thesis Statements/Topic Sentences…
Presentation transcript:

XML Data Management XSLT Exercises: Right or Wrong? Werner Nutt

Transform 4: Task Restructure the document so that movies appear according to their year, with the most recent years first, and, within the same year, according to their title countries appear in alphabetical order for each director, the first name is given before the last name actors of a movie appear according to their last name and, for actors with the same last name, according to their first name Everything else should remain as before.

Transform 4: Solution 1 <xsl:sort select=".[../name() = 'director' and (name()='first_name' or name()='last_name')]/name()"/>

Transform 7: Task Return an element “actors” with a list of “actor” elements, alphabetically sorted by last name and first name, where each actor from the movies document occurs exactly once. Each actor element should contain last name, first name, and year of birth of the actor. Hint: You may need an element to remember the last name when you sort according to first name.

Transform 7: Solution 1/1

Transform 7: Solution 1/2 <xsl:if test="not(./last_name = preceding::actor/last_name and./first_name = preceding::actor/first_name)">

Transform 7: Solution 2 <xsl:variable name="firstname" select="string(./first_name)"/> <xsl:if test="not(string(./last_name) = preceding::actor[first_name=$firstname]/last_name)">

Transform 7: Solution 3 <xsl:key name="actor-by-name-dob" match="actor" use="concat(last_name, '+', first_name, '+', birth_date)"/> <xsl:for-each select="//actor[generate-id() = generate-id(key('actor-by-name-dob', concat(last_name, '+', first_name, '+', birth_date))[1])]">

Transform 8 Extend the stylesheet for the preceding task so that an actor also contains an element “movies” with the movies starring the actor (title and year are all the info needed for a movie)

Transform 8: Solution 1 <xsl:if test="not(./last_name = preceding::actor/last_name and./first_name = preceding::actor/first_name)">

Transform 8: Solution 2/1 <xsl:key name="actors-by-name" match="actor" use="last_name"/>

Transform 8: Solution 2/2

Transform 8: Solution 2/3

Transform 8: Solution 2/3 improved <xsl:for-each select="//movie[actor/last_name=$actor/last_name] [actor/first_name=$actor/first_name]">

Transform 8: Solution 2/3 improved again <xsl:for-each select="//movie[actor[last_name=$actor/last_name] [first_name=$actor/first_name]]">

Transform 8: Solution 3 <xsl:key name="actor-by-name-dob" match="actor" use="concat(last_name, '+', first_name, '+', birth_date)"/>

Transform 8: Solution 3/2 <xsl:for-each select="//actor[generate-id() = generate-id(key('actor-by-name-dob', concat(last_name, '+', first_name, '+', birth_date))[1])]"> <xsl:for-each select="key('actor-by-name-dob', concat(last_name, '+', first_name, '+', birth_date))/..">