ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.

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.
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.
XSLT 11-Apr-17.
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.
XSL XSLT and XPath 11-Apr-17.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
Lecture 10. Back to the table example We can now return to considering in detail the first XSLT style-sheet we saw –The one which, when applied to the.
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.
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.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
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.
SD2520 Databases using XML and JQuery
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.
ECA 228 Internet/Intranet Design I Intro to XML. ECA 228 Internet/Intranet Design I HTML markup language very loose standards browsers adjust for non-standard.
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.
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
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
Semantic web course – Computer Engineering Department – Sharif Univ. of Technology – Fall XML Transformation: XSLT Semantic Web - Spring 2007 Computer.
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 About XML Things to be known Related Technologies XML DOC Structure Exploring XML.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
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.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Lecture 11 XSL Transformations (part 1: Introduction)
 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.
Accessing Data Using XML CHAPTER NINE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.
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.
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.
1 cs XSL XSL is a standard that consists of three parts: XPath (navigation in documents) XPath was taught in the DB course, so it will not be.
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.
XPath. XPath, the XML Path Language, is a query language for selecting nodes from an XML document. The XPath language is based on a tree representation.
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.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Semantic web course – Computer Engineering Department – Sharif Univ. of Technology – Fall XML Transformation: XSLT Semantic Web - Fall 2005 Computer.
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:
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
XML Introduction to XML Extensible Markup Language.
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.
XSLT: The XML transformation language
Unit 4 Representing Web Data: XML
ACG 4401 XSLT Extensible Stylesheet Language for Transformations
Chapter 7 Representing Web Data: XML
XML WITH CSS.
New Perspectives on XML
Presentation transcript:

ECA 228 Internet/Intranet Design I XSLT Example

ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text does not display value of attributes difficult to combine content from more than one document elements can only be formatted one way

ECA 228 Internet/Intranet Design I 3 XSL W3C began development in 1998 combination of 3 separate languages – XSLT: transform an XML document into other kinds of documents – XPath: provides a path to XML elements – XSL-FO: implement page layout and design ( not yet supported )

ECA 228 Internet/Intranet Design I 4 XSLT create an XSLT stylesheet XSLT is an XML document – name it with.xsl extension converts a source document to a result document transformation on client side or server side

ECA 228 Internet/Intranet Design I 5 XSLT cont … very few browsers have built-in support for XSLT – IE5x and NN6 do not fully support the W3C specs – IE6 and NN7 do support the specs client-side processors – XML Spy – MSXML – Saxon – Xalan processors transform XML into actual HTML file

ECA 228 Internet/Intranet Design I 6 XSLT cont … link the XML file to the XSLT stylesheet root element of XSLT stylesheet is either or include in the W3C namespace

ECA 228 Internet/Intranet Design I 7 XPath each component of an XML document is called a node the entire structure is called a node tree node tree consists of – the XML document itself – comments – processing instructions – namespaces – elements – element text – element attributes

8 XPath node tree: breed_report.xml root (/) element: author element: date text: Michael Barath element: breed_report processing instructions: xml-stylesheet type=“text/xsl” href=“breed_report.xsl” text: 24 November, 2004 element: time text: 08:13 element: breed element: name attribute: img = “papillon.jpg” text: Papillon element:...

ECA 228 Internet/Intranet Design I 9 XPath cont … root node ( / ) root node refers to the XML document itself – not the same as the root element of the XML doc relationships between nodes – parent: a node that contains another node – child: node contained by a parent – sibling: nodes that share a common parent – descendent: any node found below another – ancestor: any node above another node

ECA 228 Internet/Intranet Design I 10 XPath cont … nodes are distinguished by the object they refer to – element node Papillon – attribute node Papillon – text node Papillon

ECA 228 Internet/Intranet Design I 11 XPath cont … XPath provides syntax to reference nodes – absolute – relative relative to context node – any path beginning with a slash ( / ) is absolute standard/general_appearance /breed_report/breed/standard/general_appearance

ECA 228 Internet/Intranet Design I 12 XPath cont … Attribute nodes – not technically children of parent argument – syntax uses at ) sign Text node – the text contained in an element – syntax uses text( ) /breed_report/breed/name/text( )

ECA 228 Internet/Intranet Design I 13 Root Template template – collection of XSLT elements which tell processor how to transform source document root template – sets up initial code for the result document place the root template at the top of the XSLT document

ECA 228 Internet/Intranet Design I 14 Root Template cont … template contains 2 types of content – XSLT elements elements which are part of the XSLT namespace send commands to the processor – literal result elements text sent to result document but not acted on by processor, eg, all HTML tags Breed Results

ECA 228 Internet/Intranet Design I 15 Root Template cont … literal result elements – all HTML tags in XSLT document are literal result elements – to use HTML in result document simply add them to root template – any tag which does not start with the xsl namespace prefix ( xsl: ) are treated as literals – all HTML tags must follow strict XML syntax rules

ECA 228 Internet/Intranet Design I 16 Root Template cont … AKC Breed Report AKC Breed Report Information by breed

ECA 228 Internet/Intranet Design I 17 Output Method most processors output result document as HTML if tag is present in code – not part of the standard to explicitly define output type use the element – formats html xml text

ECA 228 Internet/Intranet Design I 18 Output Method cont … attribute include – method – version – encoding – omit-xml-declaration – indent – media-type

ECA 228 Internet/Intranet Design I 19 Transforming Source Document 2 ways to view result document – view in browser that contains compliant XSLT processor – use a processor that generates separate HTML file source will no longer be XML, but HTML processors: – XML Spy – Saxon – Apache Xalan – etc

ECA 228 Internet/Intranet Design I 20 Inserting Node Value – “select” attribute takes an XPath expression to identify the node ( matches only the first node ) Last Updated: at

ECA 228 Internet/Intranet Design I 21 Processing Batch of Nodes to process more than one node – note that the content node has changed from root to “breed_report/breed” – the value of the “select” attribute changes to “name”

ECA 228 Internet/Intranet Design I 22 Applying a Template rather than using it is often more efficient to create a template to apply to nodes repeated throughout the document a template to apply to all nodes

ECA 228 Internet/Intranet Design I 23 Applying a Template cont … root template: “name” template the content node has changed from “breed_report/breed” to “name” – value of select attribute changes to dot (. )

ECA 228 Internet/Intranet Design I 24 Applying a Template cont … to use the “name” template insert the following where it is to be applied, ie, from inside the root template the “name” template will be applied to every node in the document the output from the “name” template will be placed in the result document at the point where references the template

ECA 228 Internet/Intranet Design I 25 Applying a Template cont … AKC Breed Report AKC Breed Report Information by breed

ECA 228 Internet/Intranet Design I 26 Applying a Template cont … one advantage to using templates is breaking up the source nodes into manageable pieces create a template to process “group” nodes Group:

ECA 228 Internet/Intranet Design I 27 Applying a Template cont … apply the template from within the name template because this template is being applied from within the name template, not the root template, “name” is now the context node notice the XPath expression XPath uses../ to move up one level, relative to the context node

ECA 228 Internet/Intranet Design I 28 Applying a Template cont … AKC Breed Report AKC Breed Report Information by breed

ECA 228 Internet/Intranet Design I 29 Applying a Template cont … continue applying templates as needed to insert content from the source document into the result document General Appearance: Size: Head:

ECA 228 Internet/Intranet Design I 30 Attribute nodes XPath reference to reference attribute values uses the at sign )

ECA 228 Internet/Intranet Design I 31 Conditionals process nodes only if certain conditions exist – equal to a certain word – less than or greater than a particular value to run a conditional test against the content of a node …run code if condition is met

ECA 228 Internet/Intranet Design I 32 Conditionals cont …

ECA 228 Internet/Intranet Design I 33 Conditional Operators OPERATOR REPRESENTS =equal to !=not equal to <less than < =less than or equal to >greater than > =greater than or equal to

ECA 228 Internet/Intranet Design I 34 Conditionals cont … xsl:if allows for only one condition to be tested to test for several conditions nested inside xsl:choose, use series of xsl:when to define more than one condition – use as many xsl:when elements as necessary to designate default processing, use xsl:otherwise

ECA 228 Internet/Intranet Design I 35 Conditionals cont …

ECA 228 Internet/Intranet Design I 36 Sorting by default, nodes are processed in the order in which they appear in the XML document sorting allows you to order them notice the element does not have a separate closing tag can be used inside or

ECA 228 Internet/Intranet Design I 37 Sorting cont … uses the select attribute which indicates the node to sort on change original

ECA 228 Internet/Intranet Design I 38 Sorting cont … uses several attributes to control sorting attributes select = “expression” data-type = “text | number” order = “ascending | descending” case-order = “upper-first | lower-first”

ECA 228 Internet/Intranet Design I 39 Creating Elements if links or paths to images are stored in an XML node, an additional step is required to add them to the result document will cause errors ” />Link ” />

ECA 228 Internet/Intranet Design I 40 Creating Elements cont … likewise, using character entities such as < or " will return unexpected results <a href=" &quot />Link</a> <img src="images/ " />

ECA 228 Internet/Intranet Design I 41 Creating Elements cont … – takes an attribute, “name”, which has as a value the type of HTML tag to create – takes an attribute, “name”, which has as a value the name of HTML attribute to create <xsl:element name=“img” <xsl:attribute name=“src”

ECA 228 Internet/Intranet Design I 42 Creating Elements cont … to create an tag with as the src, and other appropriate values for other attributes notice the value of the “alt” attribute is set to value of breed_report/breed/name, which was already used earlier in an tag images/ 100 breed_image

ECA 228 Internet/Intranet Design I 43 Creating Elements cont … to create links with an tag, as the href the literal “Link to National Club” becomes the actual link in the result document Link to National Club

ECA 228 Internet/Intranet Design I 44 Creating Elements cont … to create HTML comments which are inserted into the result document This is a comment