CS 431 – February 28, 2005 Carl Lagoze – Cornell University

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.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
Internet Technologies1 1 Lecture 4: Programming with XSLT.
 2001 Prentice Hall, Inc. All rights reserved. 1.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XSLT (eXtensible Stylesheet Language Transformation) 1.
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.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
XSL Transformations (XSLT) Meghasyam Bokam April’1 st, 2002.
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 Workshop XSLT. XML Tagged data Hello A really interesting course, well taught Interchange of data RSS, BPEL4WS, RossettaNet … Structure document representation.
XSL Transformations Lecture 8, 07/08/02. Templates The whole element is a template The match pattern determines where this template applies Result element(s)
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
More XML XML schema, XPATH, XSLT CS 431 – February 21, 2005 Carl Lagoze – Cornell University acknowledgements to
Cornell CS 502 More XML XML schema, XPATH, XSLT CS 502 – Carl Lagoze – Cornell University.
CS 4408 Lecture 9. XSLT instruction elements We have seen that a template can contain non-XSLT text, canned text that it inserts into the result tree.
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.
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.
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.
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 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,
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
XSLT. XSL comprises of –XSLT: Is a language for transforming XML documents into other XML documents –FO: XML vocabulary for specifying formatting XSL.
Transforming XML Part II XML Document Transformation with XSLT John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
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.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
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 part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
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.
Lecture 15 XSL Transformations (part V) Acknowledgment:
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.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
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.
XML Schema – XSLT Week 8 Web site:
Some Notes on XSLT Eugenia Fernandez IUPUI. Transforming XML with XSLT XSLT processor converts XML document into a node tree Uses XSLT stylesheet for.
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.
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.
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.
August Chapter 7 - Transformation - XSLT Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
XSLT: The XML transformation language
XSL Transformations (XSLT)
Using XSLT and XPath to Transform XML Documents
eXtensible Stylesheet Language
XSLT 1.0.
Querying XML XSLT.
More XML XML schema, XPATH, XSLT
Unit 6 - XML Transformations
Presentation transcript:

CS 431 – February 28, 2005 Carl Lagoze – Cornell University XSLT Continued CS 431 – February 28, 2005 Carl Lagoze – Cornell University

Stylesheet Document or Program XML document rooted in <stylesheet> element Body is set of templates or rules match attribute specifies xpath of elements in source tree Body of template specifies contribution of source elements to result tree

Associating an XML document with a transform

XSL Execution Model Templates represent a set of rules Rule matching is done within current tree context Rules are not executed in order Default behavior is depth-first walk of tree, outputting element values http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/base.xml http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/null.xsl

Template Form Elements from xsl namespace are transform instructions match attribute value is xpath expression setting rule for execution of body Sequential execution within template Non-xsl namespace elements are literals. <xsl:apply-templates> set context to next tree step (default depth-first) re-evaluate rules

Result Tree Creation Literals – any element not in xsl namespace is inserted into result tree <xsl:text> - send content directly to output (retain whitespaces) <xsl:value-of> - extract element values (anywhere in the tree)

Result Tree Creation (cont) <xsl:copyof> - Copy selected nodes into result tree <xsl:element> - instantiate an element <xsl:attribute> - instantiate an attribute

A simple example XML base file XSLT file http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/simple.xml XSLT file http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/simple.xsl

Modifying rule set and context Mode setting <xsl:apply-templates mode=“this”> <xsl:template match=“foo” mode=“this”> <xsl:template match=“foo” mode=“that”> Context setting <xsl:apply-templates select=“//bar”> Modifies default depth-first behavior Conflict resolution rules http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/elements.xsl http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/elements2.xsl

Watch out for the default namespace!! Namespaces in XSLT The XSL document MUST know about the namespaces of elements that it references (via XPATH expressions) in the instance document http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/baseNS.xml http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/elementsNS.xsl Watch out for the default namespace!! http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/baseNoNS.xml http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/elementsNoNS.xsl

XSLT Procedural Programming Sequential programming style Basics for-each – loop through a set of elements call-template – like a standard procedure call

For-each programming example XML base file http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/foreach.xml XSLT file http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/foreach.xsl

Call-template programming example XML base file http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/call.xml XSLT file http://www.cs.cornell.edu/lagoze/courses/CS431/2005sp/Examples/Lecture10/call.xsl

Various other programming constructs Conditionals Variables (declaration and use) Once set, can’t be reset Functional programming style Use recursion Some type conversion Parameters Sorting