XSLT Streaming Terminology Understanding “Climbing” Roger L. Costello January 29, 2014.

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

Dr. Alexandra I. Cristea XPath and Namespaces.
Internet Technologies1 1 Lecture 4: Programming with XSLT.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 12 Extensible Stylesheet Language Transformations : XSLT.
XSLT 11-Apr-17.
XML, XML Schema, Xpath and XQuery Slides collated from various sources, many from Dan Suciu at Univ. of Washington.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
+ XSL eXtensible Stylesheet Language. + 2 XML Lecture Adapted from the work of Prof Mark Baker ACET, University of Reading.
Transforming XML Part I Document Navigation with XPath John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
XML Design for Streamability Roger L. Costello November 24,
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.
Lecture 13. The various node tests also work on this axis: eg node() This book has descendant-or- self nodes As expected, text nodes are included in the.
Lecture 13. The various node tests also work on this axis: eg node() This book has descendant-or- self nodes As expected, text nodes are included in the.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
A note on generating text with the xsl:value-of instruction.
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)
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
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.
1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
SD2520 Databases using XML and JQuery
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Navigating XML. Overview  Xpath is a non-xml syntax to be used with XSLT and Xpointer. Its purpose according to the W3.org is  to address parts of an.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
1/17 ITApplications XML Module Session 7: Introduction to XPath.
Introduction to XPath Web Engineering, SS 2007 Tomáš Pitner.
CSE3201/CSE4500 Information Retrieval Systems
XSLT and XPath, by Dr. Khalil1 XSL, XSLT and XPath Dr. Awad Khalil Computer Science Department AUC.
1 XPath XPath became a W3C Recommendation 16. November 1999 XPath is a language for finding information in an XML document XPath is used to navigate through.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
XPath Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Processing of structured documents Spring 2003, Part 7 Helena Ahonen-Myka.
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
Li Tak Sing COMPS311F. XPath XPath is a simple language that allows you to write expressions to refer to different parts of an XML document. We will learn.
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.
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
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.
WPI, MOHAMED ELTABAKH PROCESSING AND QUERYING XML 1.
1 XML Data Management Extracting Data from XML: XPath Werner Nutt based on slides by Sara Cohen, Jerusalem.
Unit 10 Schema Data Processing. Key Concepts XML fundamentals XML document format Document declaration XML elements and attributes Parsing Reserved characters.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
Session II Chapter 3 – Chapter 3 – XPath Patterns & Expressions Chapter 4 – XPath Functions Chapter 15 – XPath 2.0http://
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
Friday, September 4 th, 2009 The Systems Group at ETH Zurich XML and Databases Exercise Session 5 courtesy of Ghislain Fourny/ETH © Department of Computer.
CSE3201/CSE4500 XPath. 2 XPath A locator for items in XML document. XPath expression gives direction of navigation.
Designing Streamable XPath Expressions Roger L. Costello January 5,
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Lecture 23 XQuery 1.0 and XPath 2.0 Data Model. 2 Example 31.7 – User-Defined Function Function to return staff at a given branch. DEFINE FUNCTION staffAtBranch($bNo)
1 XPath. 2 Agenda XPath Introduction XPath Nodes XPath Syntax XPath Operators XPath Q&A.
1 Whitespace Handling Roger L. Costello XML Technologies.
1 The XPath Language. 2 XPath Expressions Flexible notation for navigating around trees A basic technology that is widely used uniqueness and scope in.
© 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.
Querying and Transforming XML Data
XML Path Language Andy Clark 17 Apr 2002.
Querying XML XPath.
Querying XML XPath.
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
More XML XML schema, XPATH, XSLT
Presentation transcript:

XSLT Streaming Terminology Understanding “Climbing” Roger L. Costello January 29, 2014

Question: Where is the XSLT processor positioned when at a context node?  Suppose that an XSLT processor is at this context node N (that is, the current streaming position is the element): … Exactly where is the XSLT processor positioned? The answer to this question is important because it tells us what the XSLT processor has visited when it is at a “context node”.  Is the XSLT processor positioned here (after the name of the start tag: …  Is the XSLT processor positioned here (after the attribute): …  Or is the XSLT processor positioned here (after the ns declaration): …

Answer: the XSLT processor is at the “>”  The XSLT processor is positioned at the start tag’s end angle bracket: …  So what? So the XSLT processor has visited the element, its attributes, and its namespace declarations. Obviously it has not visited its content. This is a key concept!

XSLT processor remembers ancestors and self as it streams the input  Suppose that an XSLT processor is at a context node N (that is, the current streaming position is the element). As the XSLT processor streamed through the input, it remembers all the ancestor nodes it visited, finally arriving at context node N. A B C DE N F context node The XSLT processor remembers all the ancestors of N: E, B, and A, including their attributes and namespaces. The preceding slide explained that the XSLT processor has also visited the attributes and namespace declarations of N. This is a key concept!

What does the XSLT processor remember?  The preceding slide said: The XSLT processor remembers all the ancestors of N: E, B, and A, including their attributes and namespaces.  Question: Exactly what does the XSLT processor remember?  Answer: It remembers the name of the elements, the name of the attributes, the values of the attributes, and the namespaces that are visible at each node. This is a key concept!

Climbing  A construct is climbing if, when executed, it yields the context node (self) or ancestors of the context node. Also a climbing construct can return attributes of the context node or attributes of ancestor nodes. Finally, a climbing construct can return namespaces that are visible on the context node or on any ancestor.

Why is it called “climbing”?  The term “climbing” comes from the notion that a climbing construct is one that climbs up the XML tree.

Climbing examples  Let's suppose that an XSLT program is stream-processing this XML document: A book about... Hello World  Suppose that the context node is the element (that is, the current streaming position is the element).  This XPath returns all the attributes of the context is a climbing construct.  This XPath expression: ancestor::* returns all the ancestors of the context node; ancestor::* is a climbing construct.

Climbing examples (cont.)  This XPath returns all the attributes of the parent of the context is a climbing construct.  This XPath expression:./namespace::* returns all the namespaces visible on the context node;./namespace::* is a climbing construct.

Operating on the results of a climbing construct  What can be done with the nodes returned by a climbing construct?  We must be careful because the XSLT processor remembers only a limited amount of information about the ancestor nodes.  We can apply the name function to the parent: name(..)  We can obtain the name of each ancestor: for $i in ancestor::* return name($i)  We can obtain the value of each attribute of the context node: for $i return data($i)

Can’t apply the string() function to an ancestor element  This is not legal (not streamable): apply string() to the grandparent: string(../..) Element Book Text Hello World Element Intro Element Chapter Element Title xml:lang= " EN " Text A book about … id= " abc " xmlns= " " context node Fetching this would require the XSLT processor to back up. Backing up is not allowed in streaming. Executing string(../..) would result in the XSLT processor attempting to obtain all of this data.

Lesson Learned  So you write an XPath expression to climb up the XML tree.  That XPath expression is a “climbing construct.”  Good so far.  Now you operate on those nodes that your climbing construct fetched.  Be sure that the operation doesn’t result in consuming the contents of the children of those nodes. Key concept: you are allowed to ascend but not allowed to descend afterwards.

Can apply the string() function to an ancestor element’s attribute  It is legal to apply the string() function to an ancestor element’s attributes. For example, this is legal: Element Book Text Hello World Element Intro Element Chapter Element Title xml:lang= " EN " Text A book about … id= " abc " xmlns= " " context node Executing would result in the XSLT processor attempting to obtain all of this data. That’s okay because it is data that the XSLT processor remembers on its journey to the context node.