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.

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

Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
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.
XSL eXtensible Stylesheet Language. What is XSL? XSL is a language that allows one to describe a browser how to process an XML file. XSL can convert an.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XSLT (eXtensible Stylesheet Language Transformation) 1.
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.
Rendering XML documents with XSL The most powerful approaches to rendering XML documents involve using XSL (eXtensible Stylesheet Language) XSL enables.
AJAX & By – Anupama Sharma. Defining Ajax Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together.
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 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.
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)
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
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.
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.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
XML and XSL Institutional Web Management 2001: Organising Chaos.
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.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
CSE3201/CSE4500 Information Retrieval Systems
ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.
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.
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
Another PillowTalk Presentation  2004 Dynamic Systems, Inc. Introduction to XML for SOA Lee H. Burstein,
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
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.
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.
Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
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.
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.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
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.
XSLT, XML Schema, and XPath Matt McClelland. Introduction XML Schema ▫Defines the content and structure of XML data. XSLT ▫Used to transform XML documents.
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:
XML: Extensible Markup Language
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
More XML XML schema, XPATH, XSLT
Presentation transcript:

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 “Hello World” application Enough XSLT Constructs to get started, given from a ColdFusion point-of-view

What is XSLT eXstensible Stylesheet Language: Transformations Transformation Language High-Level data manipulation language A language for transforming the structure of an XML document Primarily designed by the W3C for transforming one XML document into another

What is XSLT - cont’d The XSLT language is expressed as a well-formed XML document The XSLT language belongs to the XSLT Namespace An XSLT transformation describes rules for transforming a source tree into a result tree. This set of rules is called a “stylesheet”

What is XSLT - cont’d These “rules” have two parts Pattern Matched against nodes in the source tree Template Can be instantiated to form part of the result tree

What is XSLT - cont’d The result tree is separate from the source tree The result tree can be in a completely different form from the source tree

Output Formats Optional Parser will default the output type if the tag is omitted. Top-Level Element used to define the output type desired Enables you to specify encoding for output

Output Format - cont’d Three types of output XML output is an XML document or XML document fragment appears in the resulting output

Output Formats - Cont’d HTML Output is an HTML document Text Allows output in many other text-based formats Comma-seperated values RTF PDF EDI SQL Javascript

Why would I use XSLT XSLT is a supported w3c standard. XSLT Provides the traditional language conventions that we are used to when processing data Looping Conditional Logic Expressions Variables

Why would I use XSLT - cont’d Dynamic Efficient Facilitate separation of Data and Presentation

How I used XSLT and Why Distributed Search Application I needed to write a search engine that could function independent of the various search interfaces that we had. I needed the engine to be completely independent of the search interfaces or the search result displays.

How I used XSLT and Why I chose XML as the data format for I/O to the engine Uniform structure of Data regardless of the source Data could be easily parsed using XML parser

How I used XSLT and Why - cont’d I chose XSLT to process the XML data going into and out of the search engine With XSLT I could easily transform the data defintion output packets from the engine and create an html search form I also found XSLT to be a great way to take the search results and transform them into the various display formats we offered to our users

When would I use XSLT? When you have XML data from a source (external or internal) with no other way to process that data When the XSLT transformations are faster than the current way you have to process your XML data. Example: XSLT vs. CF processing When you need more power and flexibility than your current XML processing mechanism provides Example: CF MX XML Processing Tags/Functions

XML Parser MSXML This is the Parser that I used Free download from Microsoft Excellent Documentation Other Parsers - see chart on next slide Good understanding of XPath Used for XSLT expressions MSXML SDK - good Xpath documentation What tools will I need to use XSLT?

XML Parser Comparison Chart

To perform a transformation we need three things XML Data XSLT Stylesheet XML Parser Simple “Hello World” example

XML Data - Save as hello.xml Hello World

XSLT Stylesheet – Save as hello.xsl XSLT Example

Parsing – ColdFusion & MSXML Parser

//do not validate the xml xml.validateOnParse=false; xml.async = false; //load the xml file into the xml instance of the parser temp = xml.load("c:\inetpub\wwwroot\hello.xml"); xsl.async=false; //load the xsl file into the xsl instance of the parser xsl.load("c:\inetpub\wwwroot\hello.xsl"); output = xml.transformNode(xsl); #output#

XSLT Stylesheet Structure  The XSLT namespace has the URI Remember that an XSLT stylesheet is a well-formed XML document, therefore you must always include the corresponding closing tag. The tag is a synonym for either one is acceptable

XSLT Stylesheet Structure - cont’d  Can use any prefix, provided that there is a namespace declaration that binds the prefix to the URI of the XSLT namespace An element occurring as a child of an xsl:stylesheet element is called a top- level element

Top Level Elements

Top Level Elements - cont’d...

Templates “Match” is a pattern, the pattern is expressed using Xpath Pattern describes which nodes in the source tree the template rule matches matches the root node matches the title node

Templates - cont’d matches the Title node that is a child to the Chapter node My Title

Templates - cont’d matches the title attribute of the chapter node <chapter title=”my title” …

Templates - cont’d When the template is instantiated (a match condition is met), the instructions within the template tags are executed and the resulting data is copied to the result tree. ….instructions….

For each child of the current node Find the matching template rule Instantiate the template rule

Allows you to control the order that template rules are applied

Extract the required information from the node directly …

- Looping XSLT: … ColdFusion: …

- Conditional Logic XSLT:, ColdFusion: #name#, Result: Bob, Mary, John, Martha, Sue

- Conditional Logic XSLT: (small) (medium) (large) ColdFusion: (small) (medium) (large)

- Variables XSLT:... ColdFusion: #listgetat(list,n)# Variables may be defined Globally or Locally Local variables can be defined within a template body

Datatypes Variables are not statically typed, rather they take whatever type of value is assigned to them, just as ColdFusion does String Number Boolean Node-Set A set of nodes in the source tree Tree

Expressions Syntax of expressions is defined by the XPath Recommendation Used as attribute values for many XSLT elements

Resources XSLT – Programmer’s Reference by Michael Kay (Wrox)* W3C* Microsoft MSXML SDK Documentation* us/xmlsdk/htm/sdk_intro_6g53.asp us/xmlsdk/htm/sdk_intro_6g53.asp XSL-List * I have relied heavily on these resources not only for the application development I have done, but also in preparation for this presentation. Many of the information and examples come from one of these sources.