A note on generating text with the xsl:value-of instruction.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Internet Technologies1 1 Lecture 4: Programming with XSLT.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XPath Eugenia Fernandez IUPUI. XML Path Language (XPath) a data model for representing an XML document as an abstract node tree a mechanism for addressing.
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.
XSLT XML DBs, and Schemas Week 18 DSA. The Whisky Case study XSLT can be applied in the client. –Add a xml processing instruction to the xml to bind to.
DSA Semester 2. XML Tagged data Hello A really interesting course, well taught Interchange of data RSS, BPEL4WS, RossettaNet … Structure document representation.
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.
XSL Unit 6 November 2. XSL –eXtensible Stylesheet Language –Basically a stylesheet for XML documents XSL has three parts: –XSLT –XPath –XSL-FO.
XML Workshop XSLT. XML Tagged data Hello A really interesting course, well taught Interchange of data RSS, BPEL4WS, RossettaNet … Structure document representation.
XSL Transformations Lecture 8, 07/08/02. Templates The whole element is a template The match pattern determines where this template applies Result element(s)
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
Lecture 12. Default Processing in XSLT The default processing in XSLT is to process the XPath root node The default processing for various node types.
Cornell CS 502 More XML XML schema, XPATH, XSLT CS 502 – Carl Lagoze – Cornell University.
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
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.
SD2520 Databases using XML and JQuery
Using XSLT and XPath to Enhance HTML Documents Reference: Roger L. Costello
More on XSLT. More on XSLT variables Earlier we saw two ways to associate a value with a variable  A variable whose value is the empty string, for example.
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.
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.
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.
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
Extensible Markup and Beyond
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.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XSLT I Robin Burke ECT 360. Outline XSLT processing XSLT syntax XPath XSLT basics Lab.
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.
Computing & Information Sciences Kansas State University Thursday, 15 Mar 2007CIS 560: Database System Concepts Lecture 24 of 42 Thursday, 15 March 2007.
Database Systems Part VII: XML Querying Software School of Hunan University
XPath Aug ’10 – Dec ‘10. XPath   XML Path Language   Technology that allows to select a part or parts of an XML document to process   XPath was.
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 – XSL: Extensible Stylesheet Language Transformations (XSLT) Outline 12.1Introduction 12.2Setup.
XSLT Streaming Terminology Understanding “Climbing” Roger L. Costello January 29, 2014.
ITB Web programming for E- Commerce 1 ITB6227 Programming for E-COMMERCE Lecture Presentation of XML Documents.
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.
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.
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.
XP 1 XSLT II Robin Burke ECT 360. XP 2 Outline Conditionals Numbering Functions and operators Variables and parameters Named and recursive templates.
CSE3201/CSE4500 XPath. 2 XPath A locator for items in XML document. XPath expression gives direction of navigation.
XP 1 XSLT II Robin Burke ECT 360. XP 2 Homework #4 Forgot we hadn't covered "choose" becomes extra credit My books.xml didn't include descriptions.
XSLT I Robin Burke ECT 360. Outline History / Terminology XSLT processing XSLT syntax XPath XSLT basics Lab.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
© 2013 The MITRE Corporation. All rights reserved. XSLT Streaming Terminology Understanding “Climbing” Roger L. Costello, February 3, 2014.
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.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
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:
Module Road Map Document Transformations Web Form (ASPX) HTML Form.
Querying and Transforming XML Data
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
More XML XML schema, XPATH, XSLT
Presentation transcript:

A note on generating text with the xsl:value-of instruction

Number of nodes in the node-list chosen by the select attribute of the xsl:value-of instruction Often, there is only one node in the node-list chosen by the select attribute, for example: I found a woman. Her name is:. The text generated is the string value of the chosen node

Number of nodes in the node-list chosen by the select attribute of the xsl:value-of instruction Often, there is only one node in the node-list chosen by the select attribute, for example: I found a woman. Her name is:. The text generated is the string value of the chosen node –That is, the concatenation of the strings in the text nodes in the sub-tree of the chosen node

Number of nodes in the node-list chosen by the select attribute of the xsl:value-of instruction Often, there is only one node in the node-list chosen by the select attribute, for example: I found a woman. Her name is:. The text generated is the string value of the chosen node –That is, the concatenation of the strings in the text nodes in the sub-tree of the chosen node There is only one such text node, so only its text is output

Number of nodes in the node-list chosen by the select attribute of the xsl:value-of instruction Often, there is only one node in the node-list chosen by the select attribute, for example: I found a woman. Her name is:. The text generated is the string value of the chosen node –That is, the concatenation of the strings in the text nodes in the sub-tree of the chosen node There is only one such text node, so only its text is output

Sometimes, there may multiple text nodes in the sub-tree of a single chosen node In this example, there is still only one node in the list chosen by the select attribute –but there are two text nodes in the sub-tree of this single chosen node I found some people. Their names are:. So, the text generated is the concatenation of the strings in these two text nodes

Sometimes, there may multiple text nodes in the sub-tree of a single chosen node In this example, there is still only one node in the list chosen by the select attribute –but there are two text nodes in the sub-tree of this single chosen node I found some people. Their names are:. So, the text generated is the concatenation of the strings in these two text nodes

But, sometimes, there can be more than one node in the list chosen by the select attribute There are two nodes in the list selected here: I found some people. Their names are The selected node-list contains two person nodes

But, sometimes, there can be more than one node in the list chosen by the select attribute There are two nodes in the list selected here: I found some people. Their names are The selected node-list contains two person nodes But only one person’s name is output.

But, sometimes, there can be more than one node in the list chosen by the select attribute There are two nodes in the list selected here: I found some people. Their names are The selected node-list contains two person nodes But only one person’s name is output. Why?

Answer When a xsl:value-of instruction converts a selected node list to a text node for the result tree, it only uses only the string value of the first node in the selected list

Current node versus Context node

People often confuse these two terms This is understandable because, –in many situations the context node is the same as the current node But they are not always the same So, let's look carefully

The current node When the XSLT processor instantiates a template for some node in the document tree, then, –during the execution of the instantiation, –that node is the current node for the entire execution of the instantiation

The current node When this stylesheet is applied to this XML document, the person template is instantiated twice, once for each person node that is a descendent of the root node –During the execution of Instantiation 1, the person node whose subtree contains Celia Larkin is the current node –During the execution of Instantiation 2, the person node whose subtree contains Bertie Ahern is the current node

In XPath, the function current() returns the current node During the execution of Instantiation 1, the first person node is returned by current() and the xsl:value-of instruction computes the string value of this node, which is the text in its sole descendant text-node During the execution of Instantiation 2, the second person node is returned by current() and the xsl:value-of instruction computes the string value of this node, which is the text in its sole descendant text-node

Do. and current() mean the same thing? No.. returns the context node current() returns the current node When an XPath expression is evaluated, –the current node remains fixed –but the context node changes

At the start of evaluating an XPath expression, the context node is the same as the current node The two stylesheets above are equivalent has the same value as because, at the start of evaluating an XPath expression, the context node is the same as the current node But the context node can change during the evaluation of a complex XPath expression –this often happens when we use predicates within an XPath expression

Context node changing during XPath evaluation In this element, the XPath expression uses. twice –The first time, it refers to the root node –The second time, it refers to a person node which is being considered for inclusion in the node-set that will be returned by the XPath expression

Context node changing during XPath evaluation while current node is unchanged In this element, the XPath expression uses current() once and uses. twice –current() refers to the current node, which is a nation node –The first time,. refers to the current node, which is a nation node –The second time,. refers to a person node which is being considered for inclusion in the node-set being counted by the XPath expression

for-each loops and current() The function current() has two different meanings in a for-each loop which is iterating through a set of nodes: –in the open-tag for the loop, current() refers to the current node in the enclosing XSL element –between the tags for the loop, current() refers to the member of the selected node-set which is the subject of the current iteration

for-each loop and current() Consider the two usages of current() in this template: The name of this white-haired person is

for-each loop and current() The usage of current() in the open-tag of the for-each loop refers to the current node in the surrounding template, that is, it refers to the root node The name of this white-haired person is

for-each loop and current() The usage of current() inside the for-each loop refers to the member of the selected set of person nodes which is the subject of the current iteration through the loop The name of this white-haired person is

current() and nested for-each loops There are five usages of current() in this template In the nation,, have typical hair colour

current() and nested for-each loops The 1st usage of current() refers to the current node for the overall template In the nation,, have typical hair colour

current() and nested for-each loops The 2nd, 3rd and 4th usages of current() refer to the nation in the current iteration of the outer for-each loop In the nation,, have typical hair colour

current() and nested for-each loops The 5th usage of current() refers to the person in the current iteration of the inner for-each loop In the nation,, have typical hair colour

current() and sorting in for-each loops This template has two sort elements In the nation,, have typical hair colour

current() and sorting in for-each loops In the 1st sort element, current() refers to a nation in the node-set being sorted In the nation,, have typical hair colour

current() and sorting in for-each loops In the 2nd sort element, current() refers to a person in the node-set being sorted In the nation,, have typical hair colour

Using current() for cross- referenced sorting

An XML document with 2 cross-referenced tables This XML document contains two lists –a list of languages –a list of countries Each country has an attribute which uses an ID number to cross-refer to a language

Sorting the countries by name

Sorting the countries by name of language

Sorting by name of language, then by name of country

Using current() only when we really must

Using. only when we really must