W3C XML XSLT. Jaroslav Porubän 2008

Similar documents
XSL - Introduction and guided tour

Markup Sprachen und semi-strukturierte Daten

By Nabil ADOUI, member of the 4D Technical Support team

T XML in 2 lessons! %! " #$& $ "#& ) ' */,: -.,0+(. ". "'- (. 1

F O R U M N O K I A. Implementing Trucking Logistics with Nokia Handsets. Version 1.0; July 18, Java /XML

XML and Tools. Muhammad Khalid Sohail Khan Mat #: University of Duisburg Essen Germany

XSL Elements. xsl:copy-of

IBM Tivoli Federated Identity Manager V6.2.2 Implementation. Version: Demo. Page <<1/10>>

Data Integration through XML/XSLT. Presenter: Xin Gu

Get Success in Passing Your Certification Exam at first attempt!

XSLT - A Beginner's Glossary

WTP-101 Developing Web Applications with Standards. using W3C org standard technologies such as, HTML, CSS, XML, XSD and XSL

WTP-101 Developing Rich Internet Applications with Java Web Frameworks

XML WEB TECHNOLOGIES

Filen ex_e.xml. Her kommer koderne Det der står skrevet med fed er ændret af grp <?xml version="1.0"?>

XSLT Mapping in SAP PI 7.1

Enabling Web Services

aconferenceonxml Lesser Town Campus Prague, Czech Republic June 17-18, 2006

Interactive, dynamic Scalable Vector Graphics

INTEROPERABILITY BETWEEN VISUAL UML DESIGN APPLICATIONS AND AUTHORING TOOLS FOR LEARNING DESIGN

Electronic Bank Account Management - EBAM

IMPLEMENTING AN XML COURSE IN THE COLLEGE OF BUSINESS

Web Server Logs Analyze Using the XML Technologies

Document Builder. Thien Tran Department of Computer Science San Jose State University

2 Problem description

Building A Very Simple Website

Terms and Definitions for CMS Administrators, Architects, and Developers

INTRO TO XMLSPY (IXS)

Evaluation of Nagios for Real-time Cloud Virtual Machine Monitoring

Chapter 3: XML Namespaces

XML for RPG Programmers: An Introduction

XML and the College Website A Practical Look at the Use of XML and XSL

ART 379 Web Design. HTML, XHTML & CSS: Introduction, 1-2

Overview of DatadiagramML

XLIFF 1.2. A white paper on version 1.2 of the XML Localisation Interchange File Format (XLIFF)

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 6 Professional Graduate Diploma in IT WEB ENGINEERING

Introduction to XML Applications

Developing XML Solutions with JavaServer Pages Technology

A Form-based Approach for Application Development By Web Service Integration

Presentation / Interface 1.3

Agents and Web Services

PHP Oracle Web Development Data Processing, Security, Caching, XML, Web Services and AJAX

10CS73:Web Programming

David RR Webber Chair OASIS CAM TC (Content Assembly Mechanism)

HETEROGENEOUS DATABASE INTEGRATION FOR WEB APPLICATIONS

REDUCING THE COST OF GROUND SYSTEM DEVELOPMENT AND MISSION OPERATIONS USING AUTOMATED XML TECHNOLOGIES. Jesse Wright Jet Propulsion Laboratory,

Working With Templates in Web Publisher. Contributed by Paul O Mahony Developer Program

CSET 3100 Advanced Website Design (3 semester credit hours) IT Required

Extending XSLT with Java and C#

Ramon Martí media technology Group (MTG) Barcelona (Spain) Abstract

Introduction to Ingeniux Forms Builder. 90 minute Course CMSFB-V6 P

Oracle BI Publisher 10g Best Practices -- Session # 8633

OOML: Structured Approach to Web Development

Developers Guide. Designs and Layouts HOW TO IMPLEMENT WEBSITE DESIGNS IN DYNAMICWEB. Version: English

Stylus Studio 2010 XML Feature Comparison Matrix

Internationalization Tag Set 1.0 A New Standard for Internationalization and Localization of XML

WEBVIGIL: MONITORING MULTIPLE WEB PAGES AND PRESENTATION OF XML PAGES

How To Use X Query For Data Collection

WWW. World Wide Web Aka The Internet. dr. C. P. J. Koymans. Informatics Institute Universiteit van Amsterdam. November 30, 2007

MadCap Software. Import Guide. Flare 11

Agenda Summary of Previous Session

XML- New meta language in e-business

Building A Very Simple Web Site

Connecting e-commerce to XML

Static webpages with Pelican

Ash Deshmukh Associate Professor of Accounting and IS Pennsylvania State University - Erie. 1 Copyright 2005 Ashutosh Deshmukh, PhD

Overview Document Framework Version 1.0 December 12, 2005

Speech Interface Implementation for XML Browser

Formatting JATS. as easy as 1-2-3

OData Extension for XML Data A Directional White Paper

Technology Brief. Upgrading to FileMaker 7: How to benefit from powerful new Web Publishing capabilities

XML and Data Management

Django Assess Managed Nicely Documentation

Creating a TEI-Based Website with the exist XML Database

WebSphere Business Monitor

06 XML-based Technologies

Quality Measure Definitions Overview

Guile Present. version 0.3.0, updated 21 September Andy Wingo

Petri Net Markup Language: Implementation and Application

An Overview of XML and Related Technologies

Topics. Incorporating JSP Custom Tags Into Your Web Apps. A Quick Example of Using One. What They Are. Why Developers Should Consider Them

Design and implementation of a mobile database for Java phones

XML and Data Integration

Page: 1. Merging XML files: a new approach providing intelligent merge of XML data sets

How to Develop Stylesheet for XML to XSL-FO Transformation

An Oracle White Paper May Creating Custom PDF Reports with Oracle Application Express and the APEX Listener

IT6503 WEB PROGRAMMING. Unit-I

Formatting with FrameMaker + SGML s EDD

Sage CRM Connector Tool White Paper

Senior Android Developer

Dynamic Styling in Web Development

Cloud Computing, Interactive Websites, and Scientific Research/Education

Adding XML to the MIS Curriculum: Lessons from the Classroom

What I Wish I Had Known. In my first 30 days with umbraco

Fachbereich Informatik und Elektrotechnik XML. XML Programming. XML - Extensible Markup Language. Internet Applications, Helmut Dispert

Using XML Notepad to Read, Edit, and Parse FGDC-CSDGM XML Metadata.

Oracle Business Intelligence Publisher Overview & Best Practices

UPK Content Development Rel 11.1

Oracle Enterprise Manager

CST6445: Web Services Development with Java and XML Lesson 1 Introduction To Web Services Skilltop Technology Limited. All rights reserved.

Transcription:

XSLT Jaroslav Porubän 2008

XSL Overview extensible Stylesheet Language A language for expressing stylesheets Made of two parts XSL Transformation (XSLT) XSL Formatting Objects (XSL-FO)

XSLT - Transformation language for transformation Transforming document into Another document XHTML WML HTML document Text

Importance of Transformation Presentation Oriented Publishing document separates content from presentation Transformations can be used to style documents (HTML + CSS) Message Oriented Middleware Different content model Different structural relationship Different vocabularies

XSLT Operational Model XSLT Processor INPUT XSL Stylesheet... <xsl:template match="title"> <H3> <xsl:apply-templates/> </H3> <HR/>... OUTPUT HTML XHTML WML text

XSLT Processor Piece of software Reads an XSLT stylesheet and input document Converts the input document into an output document According to the instruction given in the stylesheet Called stylesheet processor

Example - <people> <person born="1912" died="1954"> <name> <first_name>alan</first_name> <last_name>turing</last_name> </name> <profession>computer scientist</profession> <profession>mathematician</profession> <profession>cryptographer</profession> </person> <person born="1918" died="1988"> <name> <first_name>richard</first_name> <middle_initial>m</middle_initial> <last_name>feynman</last_name> </name> <profession>physicist</profession> <hobby>playing the bongoes</hobby> </person> </people>

Example stylesheet 0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform "> </xsl:stylesheet> Applying empty stylesheet to any document Elements are traversed sequentially Content of each element is put in output Attributes are not traversed Without any specific templates XSLT processor falls back to default behavior

xsl:template Element Controls which output is created from which input match attribute contains an XPath expression XPath expression identifies input node set it matches For each node in the node set, the template contents (things between xsl:template tags) are instantiated and inserted into the output tree

Example stylesheet 1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/trans form"> <xsl:template match="people"> </xsl:stylesheet>

Example stylesheet 2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transfor m"> <xsl:template match="people"> Some people are here. </xsl:stylesheet>

Example stylesheet 3 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transfor m"> <xsl:template match="person"> A Person </xsl:stylesheet> Whitespace outside of <person> element preserved <person> element is replaced by contents of the template

Example stylesheet 4 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/trans form"> <xsl:template match="person"> <p>a Person</p> </xsl:stylesheet>

xsl:value-of Element Extracts the string value of an element or an attribute and writes it to output text content of the element after all the tags have been removed and entity references are resolved select attribute containing XPath expression identifies an element or an attribute It could be a node set, in which case, the string value of first node is taken

Example stylesheet 5 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/trans form"> <xsl:template match="person"> <p> <xsl:value-of select="name"/> </p> </xsl:stylesheet>

xsl:apply-templates Element This element applies a template to the current element or to the current element's child nodes If we add a select attribute to the <xsl:apply-templates> element, it will process only the child element that matches the value of the attribute

Example stylesheet 6 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/trans form"> <xsl:template match="person"> <p> <xsl:value-of select="name"/> </p> </xsl:stylesheet>

Example stylesheet 7 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="name"> <xsl:value-of select="last_name"/>, <xsl:value-of select="first_name"/> <!-- Apply templates only to name children --> <xsl:template match="person"> <xsl:apply-templates select="name"/> </xsl:stylesheet>

Example stylesheet 8 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform "> <xsl:template match="people"> <html> <head><title>famous Scientists</title></head> <body> <xsl:apply-templates/> </body> </html> <xsl:template match="person"> <xsl:apply-templates select="name"/> <xsl:template match="name"> <p><xsl:value-of select="last_name"/>, <xsl:value-of select="first_name"/></p> </xsl:stylesheet>

Example stylesheet 9 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="people"> <html> <head><title>famous Scientists</title></head> <body> <dl> <xsl:apply-templates/> </dl> </body> </html> <xsl:template match="person"> <dt><xsl:apply-templates select="name"/></dt> <dd><ul> <li>born: <xsl:apply-templates select="@born"/></li> <li>died: <xsl:apply-templates select="@died"/></li> </ul></dd> </xsl:stylesheet>

Modes Same input content needs to appear multiple times in the output document formatted according to different templates Titles of chapters Table of contents In the chapters themselves mode attribute xsl:template xsl:apply-templates

Example stylesheet 10 <xsl:template match="people"> <html> <head><title>famous Scientists</title></head> <body> <ul> <xsl:apply-templates select="person" mode="toc"/> </ul> <xsl:apply-templates select="person"/> </body> </html> <!-- Table of Contents Mode Templates --> <xsl:template match="person" mode="toc"> <xsl:apply-templates select="name" mode="toc"/> <xsl:template match="name" mode="toc"> <li><xsl:value-of select="last_name"/>, <xsl:value-of select="first_name"/></li>

Filtering Filtering can be done using XPath predicates

Example stylesheet 11 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/trans form"> <xsl:template match="person"> <xsl:apply-templates select="*[not(self::hobby)]"/> </xsl:stylesheet>

xsl:for-each Element The XSL <xsl:for-each> element can be used to select every element of a specified node-set Iterating through a node set The value of the select attribute is an XPath expression

Example stylesheet 12 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/ XSL/Transform"> <xsl:template match="people"> <xsl:for-each select="person"> <xsl:value-of select="name"/> <xsl:value-of select="@born"/> </xsl:for-each> </xsl:stylesheet>

xsl:if Element Tests content for certain values <xsl:if test=xpath>... </xsl:if> The test attribute is required, the value is an XPath expression

Example stylesheet 13 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/trans form"> <xsl:template match="people"> <xsl:for-each select="person"> <xsl:value-of select="name"/> <xsl:if test="@born='1912'"> Died in <xsl:value-of select="@died"/> </xsl:if> </xsl:for-each> </xsl:stylesheet>

xsl:choose Element Testing agains multiple values <xsl:choose> <xsl:when test=xpath> </xsl:when> <xsl:when test=xpath> </xsl:when>... <xsl:otherwise> </xsl:otherwise> </xsl:choose> The test attribute is required, the value is an XPath expression

Example stylesheet 14 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="people"> <xsl:for-each select="person"> <xsl:value-of select="name"/> <xsl:choose> <xsl:when test="@born='1912'"> Died in <xsl:value-of select="@died"/> </xsl:when> <xsl:otherwise> Did not born in 1912 </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:stylesheet>

xsl:sort Element XSLT provides a nice way to sort documents by element contents <xsl:sort select=selection> </xsl:sort> Sorting can only be done in the following constructs <xsl:apply-templates /> <xsl:for-each />

Example stylesheet 15 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1 999/XSL/Transform"> <xsl:template match="people"> <xsl:apply-templates> <xsl:sort select="name"/> </xsl:apply-templates> </xsl:stylesheet>

Example stylesheet 16 <xsl:stylesheet version="1.0 xmlns:xsl="http://www.w3.org/1 999/XSL/Transform"> <xsl:template match="people"> <xsl:apply-templates> <xsl:sort select="name" order="descending" / > </xsl:apply-templates> </xsl:stylesheet>

xsl:copy Element Used for creating an Document The copying is done using this construct: <xsl:copy></xsl:copy> We will also specify to the processor that our output should be instead of HTML <xml:output method="xml"/>

Example stylesheet 17 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/x SL/Transform"> <xsl:output method="xml"/> <xsl:template match="people"> <xsl:copy> <xsl:apply-templates> <xsl:sort select="name"/> </xsl:apply-templates> </xsl:copy> </xsl:stylesheet>

Example stylesheet 18 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/x SL/Transform"> <xsl:output method="xml"/> <xsl:template match="*"> <xsl:copy> <xsl:apply-templates> <xsl:sort select="name"/> </xsl:apply-templates> </xsl:copy> </xsl:stylesheet>

xml-stylesheet Processing Instruction <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="nakup.xsl"?> <nakup> <osoba meno="jano"> <polozka>chlieb</polozka> <polozka>sunka</polozka> <polozka>maslo</polozka> </osoba> <osoba meno="mara"> <polozka>paradajka</polozka> <polozka>mlieko</polozka> </osoba> </nakup>