XP 1 XSLT II Robin Burke ECT 360. XP 2 Homework #4 Forgot we hadn't covered "choose" becomes extra credit My books.xml didn't include descriptions.

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
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.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
 2001 Prentice Hall, Inc. All rights reserved. 1.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XML: Managing Data Exchange Stylesheets. Lesson Contents CSS The basic XSL file XSL transforms Templates Sort Numbering Parameters and Variables Datatypes.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
XSLT XML DBs, and Schemas Week 18 DSA. The Whisky Case study XSLT can be applied in the client. –Add a xml processing instruction to the xml to bind to.
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.
A note on generating text with the xsl:value-of instruction.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET (Using XSLT style sheet to calculate values based.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Chapter 2: Algorithm Discovery and Design
SD2520 Databases using XML and JQuery
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.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
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
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
Extensible Markup and Beyond
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Chapter 10: Procedural Programming Expert Systems: Principles and Programming, Fourth Edition.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
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 "
Extensible Stylesheet Language Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University XSL-FO XSLT.
XSLT I Robin Burke ECT 360. Outline XSLT processing XSLT syntax XPath XSLT basics Lab.
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.
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)
Computing & Information Sciences Kansas State University Thursday, 15 Mar 2007CIS 560: Database System Concepts Lecture 24 of 42 Thursday, 15 March 2007.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
XML Many-to-Many Relationship January 30, Learning Objectives ● Create a schema for a data model containing a many:many relationship ● Understand.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
JavaScript, Fourth Edition
Dr. Chunbo Chu Week 3. XML Not a replacement for HTML. XML and HTML were designed with different goals: XML was designed to transport and store data,
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.
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.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
XP 1 XSLT II Robin Burke ECT 360. XP 2 Outline Conditionals Numbering Functions and operators Variables and parameters Named and recursive templates.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Grouping Robin Burke ECT 360. Outline Extra credit Numbering, revisited Grouping: Sibling difference method Uniquifying in XPath Grouping: Muenchian method.
Grouping Robin Burke ECT 360. Outline Grouping: Sibling difference method Uniquifying in XPath Grouping: Muenchian method Generated ids Keys Moded Templates.
XSLT I Robin Burke ECT 360. Outline History / Terminology XSLT processing XSLT syntax XPath XSLT basics Lab.
Displaying Data with XSLT ©NIITeXtensible Markup Language/Lesson 6/Slide 1 of 45 Objectives In this lesson, you will learn to: * Perform conditional formatting.
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.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
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.
Querying and Transforming XML Data
PHP.
More XML XML schema, XPATH, XSLT
Presentation transcript:

XP 1 XSLT II Robin Burke ECT 360

XP 2 Homework #4 Forgot we hadn't covered "choose" becomes extra credit My books.xml didn't include descriptions

XP 3 Outline Conditionals Numbering Functions and operators Variables and parameters Named and recursive templates

XP 4 Conditional nodes XSLT supports two kinds of conditional elements: If is only if-then (no else) Choose is more general

XP 5 Example if choose

XP 6 Comparison operators

XP 7 Predicates XPath expressions test for a condition result = set of nodes that fulfill that condition Format elementName[condition]

XP 8 Example from last week

XP 9 Numbering Issues what is counted? what is the format of the numbering? how are numbers at different places in the tree related?

XP 10 Numbering Number nodes using: position() Using position(): Nodes are numbered by position in result document Can be used in conditional statements

XP 11 Using Attributes: from=pattern: pattern indicates where numbering should restart format=pattern: pattern indicates number format grouping-size, grouping-separator: indicate how digits are grouped and separator character

XP 12 Number element Nodes are numbered according to position in source document More flexibility

XP 13 Example numbering with position numbering with number element

XP 14 Number element Attributes: value=expression: any XPath expression that evaluates to a number (i.e. position()) count=pattern: specifies which nodes to count level=type: tree level for nodes to count; can be any, single, or multiple

XP 15 Numbering, cont’d count attribute indicates what is being counted default = count elements of the same name otherwise = specify an XPath pattern all matching elements included

XP 16 Numbering relationships how does the number of one element depend on other elements? Possibilities only depends on immediate siblings single depends on “parent” multiple depends on “cousins” any

XP 17 Formatting format type 1, a, A, i, I other punctuation

XP 18 Example table of contents

XP 19 Internal computations Often performed using XPath sort of like SQL Can perform calculations of nodes selected by an XPath expression XPath functions

XP 20 XPath numerical functions

XP 21 XPath string functions

XP 22 XPath operators

XP 23 Example Calculating the average Problem redundant calculation

XP 24 Variables Not variable! User-defined name that stores a particular value or object Types: number text string node set boolean result tree fragment

XP 25 Using variables Syntax: Example: Names are case-sensitive Value only set once upon declaration Enclose text strings in single-quotes

XP 26 Using variables, cont'd Value can be XPath expression Value can be XML fragment Syntax:

XP 27 Variable reference Syntax: $variable-name Example: $Months Except Referencing tree fragments: Do not use $variable-name Use to reference value

XP 28 Global variables Can be referenced from anywhere within the style sheet Must be declared at the top level of the style sheet, as a direct child of the element Must have a unique variable name Evaluated only once when stylesheet is invoked

XP 29 Local variables Referenced only within template Can share name with other local or global variable Reevaluated when template is used

XP 30 Examples average with variables

XP 31 Number format XPath function format-number Syntax: format-number(value, format) Example: format-number( , '#,##0.00') displays 56,823.85

XP 32 Number format syntax

XP 33 Decimal format XSL element for defining number formats Named decimal format passed as argument to format-number

XP 34 Example average with format

XP 35 Parameters Similar to variables, but: Value can be changed after it is declared Can be set outside of scope Syntax: Example: To reference: $param-name

XP 36 External parameters Depends on XSLT processor Some work by appending parameter value to url Command line processors allow external parameter setting: MSXML Saxon

XP 37 Template parameters Local in scope Created inside element Used to pass parameters to template

XP 38 Idea Called template contains param definitions Calling template place element in element or element Syntax: No error if calling param name does not match template param name

XP 39 Named template Template not associated with node set Collection of commands that are accessed from other templates in the style sheet Syntax: XSLT elements

XP 40 Calling named templates Syntax:...

XP 41 Example average with named template

XP 42 Functional programming Functional programming language: Relies on the evaluation of functions and expressions, not sequential execution of commands Different from C family of languages LISP, Scheme, ML

XP 43 Templates as functions A template supplies a result fragment incorporated into the final document think of this as substitution function call replaced by result

XP 44 Iteration How to handle iteration with templates? stars for ratings Possibilities convert numbers into node sets weird since node sets are supposed to come from the document recursive templates

XP 45 Recursion base case when do I stop? recursive case how do I bite off one piece call template again with the rest

XP 46 Example Template: star(rating) desired output: # stars = # in rating Base case: rating = 0 output: nothing Recursive case rating > 0 output: * plus result of star (rating-1)

XP 47 Example, cont'd star(3) replaced by * star(2) replaced by ** star(1) replaced by *** star(0) ***

XP 48 Pseudocode stars (n) if n = 0 return '' else return '*' + stars(n-1)

XP 49 Recursive pattern Syntax with :

XP 50 Example ratings with stars

XP 51 Another example "best rated" jeep supplier Finding maximum built into XSLT 2.0

XP 52 Recursive statement?

XP 53 What about the name?

XP 54 Homework #5 Case 1 from Chapter 7 Plus doing it "correctly" with CSS Also 10/27 Schema milestone for final project