ACG 4401 XSLT Extensible Stylesheet Language for Transformations

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

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.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
XSLT (eXtensible Stylesheet Language Transformation) 1.
XML: Managing Data Exchange Stylesheets. Lesson Contents CSS The basic XSL file XSL transforms Templates Sort Numbering Parameters and Variables Datatypes.
+ 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.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
Rendering XML documents with XSL The most powerful approaches to rendering XML documents involve using XSL (eXtensible Stylesheet Language) XSL enables.
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.
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)
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.
XML – Extensible Markup Language XML eXtensible – add to language. Markup – delimit info using tags. Language – a way to express info.
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
CSE3201/CSE4500 Information Retrieval Systems
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
CIS 451: XSL Dr. Ralph Westfall February, Problems With XML no formatting capabilities contra formatting tags like, etc. in HTML CSS can be used.
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,
Module Road Map Credit Categories Assignment 2 Credit Category 2 You are able to demonstrate how data may be filtered using Xpath You are able to demonstrate.
XML About XML Things to be known Related Technologies XML DOC Structure Exploring XML.
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 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.
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
Lecture 11 XSL Transformations (part 1: Introduction)
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
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.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
 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.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
1 XMLXSL(T) and CSS NOEA/PQC (rev. fen) 2007 Stylesheets CSS:Cascading Style Sheets XSL(T):eXtended Stylesheet Language (Transformations)
1 Whitespace Handling Roger L. Costello XML Technologies.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
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.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
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:
August Chapter 7 - Transformation - XSLT Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
In this session, you will learn to:
XSLT: The XML transformation language
Unit 4 Representing Web Data: XML
Displaying XML Data with XSLT
XSLT 1.0.
Chapter 7 Representing Web Data: XML
Extensible Markup Language
Applying eXtensible Style Sheets (XSL)
XML WITH CSS.
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
WHAT IS XSLT?.
XSL XSLT and XPath 24-Feb-19.
Unit 6 - XML Transformations
Presentation transcript:

ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL

XSLT Extensible Stylesheet Language Transformations Hey it’s based on XML Stylesheet What the data will look like Language Scripting Transformations to change the structure and markup of an XML document so that it can serve another purpose Reuse, Repurpose, calculate, sort, etc.

XSLT Parts XSL XSLFO Transform Instance Document to different Form HTML, XHTML, XML (new), PDF XSLFO For formatting data

Re-Purpose The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method of presenting the data Presentation Linkbase XSLT

A UBL Catalogue Node Tree Name PartyName Party + Provider Party + Receiver Party + Catalogue Line ID Name IssueDate Leaf Nodes Branch Nodes Catalogue

Transformation Requires xml code in Two Documents Instance Document 2nd Prolog line linking instance document to XSLT document XSLT Document Contains script for selecting elements to be displayed

XSLT Must have 2nd prolog linking to .xsl XML Instance document XML Processor XML Result document XSLT Instructions 2 Inputs: Instance (source) & XSLT (transformation script) Processing Browser Output: result document

Transforming your Instance Document Contain elements and data but.. Does NOT contain formatting information Add an additional prolog statement Connects your .xml to your .xsl document <?xml-stylesheet type=“text/xsl” href=“name.xsl”?> xml-stylesheet Tells the processor to use the stylesheet file to transform the data in the .xml document href= Points to location of .xsl document.

XSLT (the XML code) Root Element namespace declaration <xsl:stylesheet xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” version="1.0"> All other namespaces used in the instance document (MUST MATCH) Default namespaces (e.g. without the prefix) are not allowed in XSLT v 1.0 Need to make up a prefix Don’t forget this!

XSLT Scripting Code Sum Formatting Mathematical Operations Elements used: templates for-each value-of Functions Formatting Format-number Sum Mathematical Operations +, -, *, div

Templates Element that follows root element What elements from .xml are being used? Templates provide answer Processing Elements from Instance against Template created in XSLT <xsl:template match=“/”> / = Look in entire source document

How to transform data <HTML> container Tells processor transformation will use html tags. Remaining code between <HTML> and </HTML> code is the data to be transformed and the formatting code for the transformation

Lets look at Node Paths <?xml version="1.0"?> <Inventory> <InventoryItem> <Name>Basketball</Name> <IdNumber>12345</IdNumber> <Cost units="USD">12.50</Cost> <RetailPrice units="USD">25.00</RetailPrice> </InventoryItem> </Inventory>

value-of select Selects and transforms/formats Displays the value of the selected element At the end of the node Based on select attribute You must point to the “node” you want displayed “Full node path” “Inventory/InventoryItem/IdNumber” = 12345 “//elementname” Used when one and only one element has the name Start at root and look for element name. “//IdNumber” = 12345 <xsl:value-of select=“NodeName”/> Value-of select can use a function.....

Functions Numeric ceiling() floor() number() round() sum() String concat() contains() normalize-space() starts-with() string() string-length() substring() substring-after() substring-before() translate()

format-number() function format-number function has two arguments Number (node path to the number) Pattern (see formatting patterns) <xsl:value-of select =“format-number(Inventory/InventoryItem/Cost,’$#.00’)”/> Number pattern

Formatting Numbers 0 A digit. # A digit, zero shows as absent. $ prefix . (period) Placeholder for decimal separator. , Placeholder for grouping separator. ; Separate formats. - Default prefix for negative. % Multiply by 100 and show as a percentage. X Any other characters can be used in the prefix or suffix. ‘ Used to quote special characters in a prefix or suffix.

for-each loop Selects All elements contained in a node-set Node-set is declared with select attribute Additional .xsl code provide instructions for what to do with selected data What transformations to make HTML, and XSL tags combined. <xsl:for-each select=“Inventory/InventoryItem>

Accessing Remote Instance Docs document() function <xsl:value-of select=“document(‘URI.xml’)/xpath”/>

Output (HTML) <HTML> <Center> All tags must be closed! Transformation will be to an HTML doc. <Center> All tags must be closed!

Defining Tables in HTML <Table Border=“n”> Tells browser to begin making a table <TR> (table row) Tells browser to insert a new row <TH> (table header) Tells browser to insert a new column in the new row AND use text as heading (bold) <TD> (table data) Tells browser to insert a new column in the new row Close all tags </TD>, </TR>, </Table>

Table with 2 rows and 3 columns <TABLE BORDER=“1”> <TR> <TD>r1c1</TD> <TD>r1c2</TD> <TD>r1c3</TD></TR> <TD>r2c1</TD> <TD>r2c2</TD> <TD>r2c3</TD></TR>