1 Whitespace Handling Roger L. Costello XML Technologies.

Slides:



Advertisements
Similar presentations
1 The MITRE Using XSL to Generate XHTML Documents Roger L. Costello XML Technologies.
Advertisements

 2001 Prentice Hall, Inc. All rights reserved. 1.
XSL eXtensible Stylesheet Language. What is XSL? XSL is a language that allows one to describe a browser how to process an XML file. XSL can convert an.
XSLT (eXtensible Stylesheet Language Transformation) 1.
+ XSL eXtensible Stylesheet Language. + 2 XML Lecture Adapted from the work of Prof Mark Baker ACET, University of Reading.
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)
1 XSL – XML Stylesheet Language. 2 XSL XSL = XML Stylesheet Language XSL cosists of –XPath (navigation in documents) –XSLT (T for transformations) –XSLFO.
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 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.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents into Text Files Roger L. Costello XML Technologies.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET (Using XSLT style sheet to calculate values based.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.
Object Oriented Programming III1 XSLT Processing XML using XSLT Using XPath.
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)
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.
Using XSLT and XPath to Enhance HTML Documents Reference: Roger L. Costello
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
Comparing XSLT and XQuery Michael Kay XTech 2005.
CSE3201/CSE4500 Information Retrieval Systems
XSL XML Stylesheet Langauage. XPath Notation for addressing elements in an XML document /xyz - selects the root element /xyz/abc - selects all elements.
CIS 451: XSL Dr. Ralph Westfall February, Problems With XML no formatting capabilities contra formatting tags like, etc. in HTML CSS can be used.
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Transforming XML Part II XML Document Transformation with XSLT John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
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 "
The Information School at the University of Washington INFO 440: Information System Design Fall 2003 * Bob Boiko * MSIM Associate Chair XML Transforms.
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)
XML Patch Operations based on XPath selectors Jari Urpalainen IETF62 Minneapolis.
XSLT Introduction. XSLT is the transformation part of XSL An XSLT file contains rules which are applied against and XML file to produce an output Outputs.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 – XSL: Extensible Stylesheet Language Transformations (XSLT) Outline 12.1Introduction 12.2Setup.
Lecture 15 XSL Transformations (part V) Acknowledgment:
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Applying eXtensible Style Sheets (XSL) Ellen Pearlman Eileen Mullin Programming.
XSLT Streaming Terminology Understanding “Climbing” Roger L. Costello January 29, 2014.
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.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
 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.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
Designing Streamable XPath Expressions Roger L. Costello January 5,
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
XSLT I Robin Burke ECT 360. Outline History / Terminology XSLT processing XSLT syntax XPath XSLT basics Lab.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML Schema – XSLT Week 8 Web site:
Some Notes on XSLT Eugenia Fernandez IUPUI. Transforming XML with XSLT XSLT processor converts XML document into a node tree Uses XSLT stylesheet for.
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.
Unit 4 Representing Web Data: XML
Using XSLT and XPath to Transform XML Documents
ACG 4401 XSLT Extensible Stylesheet Language for Transformations
More Sample XML By Sadia Anjum.
WHAT IS XSLT?.
Presentation transcript:

1 Whitespace Handling Roger L. Costello XML Technologies

2 What is Whitespace? The following characters are considered to be whitespace characters: –space (#x020) –tab (#x09) –newline (#x0A) –carriage return (#x0D)

3 Whitespace-only Nodes Identify all of the whitespace-only nodes in this XML document: Text with surrounding whitespace Text with NO surrounding whitespace Text with embedded whitespace see whitespace-example01

4 Easy to identify in tree form Document / PI Element WhitespaceTest Element a Text "cr " Text " Text,,," Text "Text …" Text "Text …" Text " Text "cr " Element b Text "cr " Element c Text "cr " Element d Text "cr "... Note: cr = carriage return.

5 This XSL instruction tells the XSL Processor to "go to each child node and execute the template rule for the node" –The child nodes include the text nodes of course! Thus, if you write an identity transformation stylesheet then the output document will have the same indentation as the input document.

6 Strip whitespace-only nodes Problem: create a stylesheet which does an identity transformation, but it strips all indentation. Text with surrounding whitespace Text with NO surrounding whitespace Text with embedded whitespace Input: Text with surrounding whitespace... Output:

7 This XSL instruction tells the XSL Processor to "go to each child element node and execute the template for the node." Thus, this will result in skipping the text nodes that are giving the indentation. Will this give us the desired output? No! Output: In addition to stripping out the whitespace-only nodes (i.e., the indentation nodes), we have also stripped out the data.

8 This XSL instruction tells the XSL Processor to strip out all whitespace-only nodes in the XML document, prior to any processing. Thus, a stylesheet which does an identity transformation will yield an output document with no indentation. But there's one small problem...

9 We have element nodes that contain whitespace-only! Text with surrounding whitespace Text with NO surrounding whitespace Text with embedded whitespace The value of and is whitespace-only! So their values will get removed also. We don't want these values removed.

10 This XSL instruction has higher precedence than xsl:strip-space. It tells the XSL Processor "the space in elements and must be preserved".

11 xml:space="preserve" This is a standard XML attribute that you can add onto any XML element. This attribute instructs any application (e.g., an XSL Processor) that processes the element "the space in this element is to be preserved". This attribute has precedence over xsl:strip- space.

12 This stylesheet does an identity transformation, plus strips indentation <xsl:stylesheet xmlns:xsl=" version="1.0">

13 Notes about xsl:strip-space indicates that all whitespace-only text nodes should be stripped. indicates that the whitespace-only text nodes within,, and are to be stripped.

14 Note: only immediate children are stripped Element Foo Text "cr " Element bar Text "cr " Text "cr " Element gab Text "cr " will result in stripping only these two nodes: That is, only the immediate children are stripped.