XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.

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

Transforming XML Part I Document Navigation with XPath John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
XPath Eugenia Fernandez IUPUI. XML Path Language (XPath) a data model for representing an XML document as an abstract node tree a mechanism for addressing.
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.
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.
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.
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
Object Oriented Programming III1 XSLT Processing XML using XSLT Using XPath.
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.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
SD2520 Databases using XML and JQuery
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.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
XSLT Brent P. Christie Major USMC. XSLT Overview  What is XSLT? –XSL is the Extensible Style Language. –It has two parts: the transformation language.
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
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.
CSE3201/CSE4500 Information Retrieval Systems
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.
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:
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
Lecture 22 XML querying. 2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
Processing of structured documents Spring 2003, Part 7 Helena Ahonen-Myka.
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
Li Tak Sing COMPS311F. XPath XPath is a simple language that allows you to write expressions to refer to different parts of an XML document. We will learn.
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)
IS432: Semi-Structured Data Dr. Azeddine Chikh. 6. XML Path (XPath)
XPath Aug ’10 – Dec ‘10. XPath   XML Path Language   Technology that allows to select a part or parts of an XML document to process   XPath was.
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 – XSL: Extensible Stylesheet Language Transformations (XSLT) Outline 12.1Introduction 12.2Setup.
SDPL 2001Notes 5: XSLT1 5. Document Transformations n XSLT (W3C Rec. Nov-99) –A language for transforming XML documents »representative of features common.
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.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
Session II Chapter 3 – Chapter 3 – XPath Patterns & Expressions Chapter 4 – XPath Functions Chapter 15 – XPath 2.0http://
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
CSE3201/CSE4500 XPath. 2 XPath A locator for items in XML document. XPath expression gives direction of navigation.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
1 Technologies for an Information Age:.opennet Extensible Style Language—XSLT Fall Semester 2001 MW 5:00 pm - 6:20 pm CENTRAL (not Indiana) Time Bryan.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
1 The XPath Language. 2 XPath Expressions Flexible notation for navigating around trees A basic technology that is widely used uniqueness and scope in.
5 Copyright © 2004, Oracle. All rights reserved. Navigating XML Documents by Using XPath.
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.
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:
Lecture 2.01 Data Modeling I: XML & XSLT Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute Mount Sinai Hospital Toronto, ON.
Query Languages for XML
Product Training Program
ACG 4401 XSLT Extensible Stylesheet Language for Transformations
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
More XML XML schema, XPATH, XSLT
Presentation transcript:

XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML document (or a part of it) –HTML document –or any other text document (although not designed to do so) An XSLT processor takes an XSLT stylesheet to convert an input document into the output document

XSLT stylesheet consists of template rules (xsl:template elements) each rule describes: –a pattern to match (e.g. element name) –set of parameters (optionally) –a sequence constructor: data (template) to output, typically some markup some data copied from source document some new data

Peter Kováč FMFI UK FiF UK Karol Nový FMFI UK <xsl:value-of select="FirstName"/>, <xsl:value-of select="LastName"/>, <xsl:value-of select="Study[1]/Faculty"/> (<xsl:value-of Peter, Kováč, FMFI UK (1070) Karol, Nový, FMFI UK (1070)

Documents modeled as trees with following kinds of nodes: –the root (/) –element –attribute –text –namespace –processing instruction –comment

Basic algorithm XSLT processor accepts an input tree and produces an output tree Transformation is done by evaluating the sequence constructor of the initial template. –initial template: if not set explicitly, it is template rule selected for processing initial context node (default: root node) –other templates can be “called” from here Default templates: –for elements: call apply-templates on all child elements –for text and attributes: copy string value of node

Patterns – examples root node: / (relative) element name: e.g. Student, Person, FirstName, Study (relative) path: e.g. Person/Study, Person/Study/Faculty element at any level: e.g. Person//Faculty, //Study attribute: wildcard: *, cdo:*, Person/*/Faculty, “or” operator: FirstName|Lastname, test with [XPath expression]: –Person[FirstName=‘Peter’], –Study[position()=last()], –Person[Study]

Sequence constructors Sequence constructor can consist of –text nodes –literal result elements –XSLT instructions –extension instructions

XSLT instructions creating new nodes –xsl:document, xsl:element, xsl:attribute, xsl:text, xsl:value-of,... conditional or repeated execution –xsl:if, xsl:choose, xsl:for-each,... invoking other templates –xsl:apply-templates, xsl:next-match, xsl:call-template,... declaring variables –xsl:variable, xsl:param other

Creating new nodes a-text... a-value a-text

Conditional and repeated execution

Invoking other templates –finds a template for each node in the input sequence and invokes it –default: all child nodes (elements, PI’s, comments, text – not attributes!) –can be nodes that are not descendants

Variables definition (global/local):... use: $variable-name e.g.

Parameters declaration (at the level of stylesheet, template, or function): use like variables ($xxx) When invoking templates:

XPath 2.0 all values = sequences of –nodes, or –simple values, e.g. int, string, boolean, date single value = sequence of length 1 empty sequence: () single value: „a“ or („a“) general sequence: („a“, „b“, „c“) from

Constants string literals –"This is a test.“ –"This is a ‘test'." numeric constants –14 (integer) – (fixed point decimal) –3.2e-7 (double precision floating point number) no boolean constants –use true(), false() functions other –xs:dateTime(" T15:00:00Z") –xs:float("10.7") –...

Various variables: $name function calls: fnc(arg1, arg2,...) comparisons / tests / conditionals: –for atomic values: eq, ne, lt, le, gt, ge –for sequences: =, !=,, >=: true if any pair has that relationship! –is (testing node identity) –deep-equal (node-sequence-1, node-sequence-2) – > (testing node precedentness in document order) –instance of, castable as –if (E1) then E2 else E3 –some/every $x in E1 satisfies E2

Accessing documents axis :: node-test axes available: –child (default), attribute ancestor, ancestor-or-self, descendant, descendant-or-self, preceding/following, preceding/following-sibling, parent, self node test - examples: –node name –prefix:*, *:localname –text(), node(), comment(), element(), element(Name), attribute(), attribute(Name)

Accessing documents (2) E1 / E2 / E3 means: –first we have an input sequence (of nodes), S1 –then we apply expression E1 on each of them, resulting in S2 –then we apply E2 on each of them, resulting in S3 –then we apply E3 on each of them, resulting in S4 e.g. = /child::Students/child::Person[attribute::id=‘ ’]/child::Study results in two elements “Study” –/Students/Person/Study (three elements “Study”) results in text node “Peter” results in string “Peter”

Peter Kováč FMFI UK FiF UK Karol Nový FMFI UK