1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.

Slides:



Advertisements
Similar presentations
1 The MITRE Using XSL to Generate XHTML Documents Roger L. Costello XML Technologies.
Advertisements

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.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XSLT (eXtensible Stylesheet Language Transformation) 1.
XSL XSLT and XPath 11-Apr-17.
+ XSL eXtensible Stylesheet Language. + 2 XML Lecture Adapted from the work of Prof Mark Baker ACET, University of Reading.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
JAXP Transformation Package and Xalan Extensions 黃立昇
Rendering XML documents with XSL The most powerful approaches to rendering XML documents involve using XSL (eXtensible Stylesheet Language) XSL enables.
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.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
1 Copyright (c) [2001]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Enhance HTML Documents Roger L. Costello XML Technologies.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents into Text Files Roger L. Costello XML Technologies.
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
1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.
Object Oriented Programming III1 XSLT Processing XML using XSLT Using XPath.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Internet Technologies1 XSLT Processing XML using XSLT Using XPath.
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.
Using XSLT and XPath to Enhance HTML Documents Reference: Roger L. Costello
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.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
Comparing XSLT and XQuery Michael Kay XTech 2005.
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 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Transforming XML Part II XML Document Transformation with XSLT John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
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 "
XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
Extending XML Schemas XML Schemas: Best Practices A set of guidelines for designing XML Schemas Created by discussions on xml-dev.
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)
Yet more on XSLT. Regular expression handling in EXSLT We saw that the EXSLT extensions are divided into a group of modules, each of which has its own.
 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.
1 Overview of XSL. 2 Outline We will use Roger Costello’s tutorial The purpose of this presentation is  To give a quick overview of XSL  To describe.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
 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 Whitespace Handling Roger L. Costello XML Technologies.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
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.
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:
Session IV Chapter 14 – Chapter 14 – XSLThttp://
Product Training Program
Using XSLT and XPath to Transform XML Documents
Using Extension Elements and Extension Functions with XSLT and XPath
XSLT 1.0.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations
Applying eXtensible Style Sheets (XSL)
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
WHAT IS XSLT?.
Presentation transcript:

1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello XML Technologies

2 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Extension Elements The XSL processor understands how to process xsl:template, xsl:apply-templates, xsl:if, xsl:for-each, etc –That is, it understands the vocabulary in the XSL namespace XSL Processor implementers oftentimes provide additional elements that you may use in your stylesheet –These extension elements will belong to a namespace defined by the implementer

3 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Example Extension Element: instruct the xsl processor to output to another file Many of the xsl processor implementers provide an extension element that instructs the xsl processor to output the contents of the element to another file. –Thus, your stylesheet can generate multiple output files! XSL Processor XML XSL

4 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Vendor-specific Each implementor gives the extension element a different name: –saxon calls it: output –xalan calls it: write

5 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. How to use an extension element 1. Declare the namespace that the extension element belongs to: saxon: xmlns:saxon=" xalan: xmlns:xalan=" 2. Indicate that any element that is namespace qualified by the prefix is an extension element, i.e., it has a specific meaning and should be processed using the implementer's code: saxon: extension-element-prefixes="saxon" xalan: extension-element-prefixes="xalan" 3. Use the extension element: saxon: -- anything in here will go to the file specified --- xalan: -- anything in here will go to the file specified ---

6 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Problem Write a stylesheet which outputs the platinum members in one file, the gold members in another file, and the third file is an index to the other two files.

7 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. FitnessCenter.xsl FitnessCenter.xml XSL Processor gold.xml new-FitnessCenter.xml platinum.xml

8 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. This element instructs an xsl processor to copy to the output file the element selected by xpath, plus all its descendents. This instructs the xsl processor to copy everything from to i.e., the Member element and all its descendents.

9 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. <xsl:stylesheet xmlns:xsl=" xmlns:saxon=" extension-element-prefixes="saxon" version="1.0"> See extension-example01

10 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Don’t forget extension-element- prefixes The extension-element-prefixes is used to tell the xsl processor, "whenever you encounter an element with any of these prefixes listed here you are to treat it as an extension element, and process it using the implementer's code" If you fail to do so the xsl processor will simply output the element literally (see extension-example02)

11 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Extension Functions We have seen some of the functions that XSL provides: substring(), contains(), substring-before, etc. Many xsl processor implementers provide additional functions. You signify that a function is an extension function by namespace qualifying it.

12 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Dynamic (run-time) Evaluation Many xsl processor implementers give you an extension function that enables you to dynamically evaluate an expression. –That is, you can generate the expression on the fly, or read it in from an external file. SAXON provides an extension function called evaluate to do this.

13 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. FitnessCenter.xsl FitnessCenter.xml XSL Processor checkFitnessCenter.xml results.xml This file contains expressions that are dynamically evaluated against FitnessCenter.xml Example: provide an xpath expression that ensures that each Member's level attribute is either Platinum or Gold, and nothing else.

14 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. <xsl:stylesheet xmlns:xsl=" xmlns:saxon=" extension-element-prefixes="saxon" version="1.0"> <xsl:variable name="tests" select="document('checkFitnessCenter.xml')"/> SUCCEEDED FAILED Now any references is to elements in checkFitnessCenter.xml Takes us back to referencing elements in FitnessCenter.xml