Tài liệu Module 7: Formatting and Transforming: XSL and XSLT pdf

36 632 0
Tài liệu Module 7: Formatting and Transforming: XSL and XSLT pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Module 7: Formatting and Transforming: XSL and XSLT Contents Overview Lesson: Defining XSL Lesson: Transforming XML Using XSLT Lesson: XSLT in the Microsoft NET Framework 20 Lab 7: Creating and Editing XSLT in FrontPage 2002 and Visual Studio NET 25 Review 31 Information in this document, including URL and other Internet Web site references, is subject to change without notice Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, places or events is intended or should be inferred Complying with all applicable copyright laws is the responsibility of the user Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property  2001 Microsoft Corporation All rights reserved Microsoft, MS-DOS, Windows, Windows NT, ActiveX, BackOffice, bCentral, BizTalk, FrontPage, MSDN, MSN, Netshow, PowerPoint, SharePoint, Visio, Visual Basic, Visual C++, Visual C#, Visual InterDev, Visual Studio, Windows Media, and Xbox are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A and/or other countries The names of actual companies and products mentioned herein may be the trademarks of their respective owners Module 7: Formatting and Transforming: XSL and XSLT iii Instructor Notes Presentation: 45 Minutes Lab: 20 Minutes This module introduces Extensible Stylesheet Language Transformations (XSLT) and the role it plays in the Microsoft® NET Framework XSLT is a subset language of Extensible Stylesheet Language (XSL) XSLT is a difficult topic with many subtle features and capabilities There is not time to explore most of these features and capabilities in this module The aim of this module is to provide an introduction to XSLT without completely overwhelming the participants Emphasize at the outset that XSLT is the subject of an entire five-day course, Course 1913A, Exchanging and Transforming Data Using XML and XSLT This is not an easy topic to well Teaching this module without preparation will make participants confused about XSL and XSLT Prepare thoroughly for this topic After completing this module, participants will be able to: ! Explain the relationship between XSL and XSLT ! Compare XSLT with Extensible Stylesheet Language Formatting Objects (XSL-FO) ! Explain the syntax of a basic XSLT style sheet ! Write a basic XSLT style sheet that transforms an XML document Materials and Preparation This section provides the materials and preparation tasks that you need to teach this module Required Materials To teach this module, you need the following materials: ã Microsoft PowerPointđ file 2500A_07.ppt Preparation Tasks To prepare for this module: ! Read all of the materials for this module ! Complete the lab ! Attend Course 1913A or read it and complete the labs ! On the World Wide Web Consortium (W3C) site, read about XSL, XSLT, XSL-FO, and XML Path Language (XPath) in as much depth as possible Make sure that you understand the distinctions and relationships between these technologies and languages ! Read the topics about XSLT in the Microsoft NET Framework software development kit (SDK) in Microsoft Visual Studio® NET iv Module 7: Formatting and Transforming: XSL and XSLT Module Strategy Use the following strategy to present this module: ! Defining XSL This lesson provides an introduction to XSL and XSLT Explain the relationship between XSL and its subset languages: XPath, XSLT and XSL-FO Explain why XSLT was developed You will present an overview of XSL and present a simple example of a style sheet based on the working draft of XSL that applies formatting to XML ! Transforming XML Using XSLT In this lesson, start by discussing the power of XSLT and the many ways that you can use it You may want to bring extra examples to this section, but be mindful of the timing You will present an overview of XSLT and present a simple example of a style sheet that transforms XML ! XSLT in the Microsoft NET Framework The goal of this lesson is to describe the nature of XSLT support in the NET Framework and the particular role of the XslTransform class in the “System.Xml.Xsl” namespace Read as thoroughly as you can about this topic Search for the word “xlst” in the NET Framework SDK Familiarize yourself with the ways in which XslTransform works with other parts of the NET Framework and its classes so that you can explain the diagram in this lesson adequately Ensure that you teach this topic as an overview, because the details about many of the methods, classes, and components might overwhelm participants Stress that there is significant documentation on this topic and that there is extensive and diverse support in the NET Framework for XSLT If you have time, you may wish to explain the concepts of the XmlReader and XmlWriter classes further, but be sure not to go into too much detail Finally, point your participants to other courses that cover this topic in more detail Module 7: Formatting and Transforming: XSL and XSLT Overview ! Defining XSL ! Transforming XML Using XSLT ! XSLT in the Microsoft NET Framework *****************************ILLEGAL FOR NON-TRAINER USE****************************** Introduction This module introduces Extensible Stylesheet Language (XSL) and one of its subset languages, Extensible Stylesheet Language Transformations (XSLT) XSLT plays an important role in the handling of Extensible Markup Language (XML) sources Objectives After completing this module, you will be able to: ! Explain the relationship between XSL and XSLT ! Compare XSLT with Extensible Stylesheet Language Formatting Objects (XSL-FO) ! Explain the syntax of a basic XSLT style sheet ! Write a basic XSLT style sheet that transforms an XML document Note To monitor the development of W3C activity regarding XSL and XSLT, go to the XSL page at http://www.w3.org/style/xsl, the XSLT page at http://www.w3.org/TR/xslt, and the XSL working group page at http://www.w3.org/Style/2000/xsl-charter.html For more information about XSLT, see Course 1913A, Exchanging and Transforming Data Using XML and XSLT You can apply the principles that you learn in Course 1913A to Microsoft® NET languages (Microsoft Visual Basic® NET and Microsoft Visual C#™ NET), but the specific syntax and methods used with the XSLT syntax is different Module 7: Formatting and Transforming: XSL and XSLT Lesson: Defining XSL ! What Is XSL? ! XSL Style Sheets *****************************ILLEGAL FOR NON-TRAINER USE****************************** Introduction This lesson focuses on XSL and XSLT Understanding the difference between them will help you to use them appropriately in your XML projects The actual processing of XML and XSLT depends on the particular capabilities of the browser and processor in use Not all browsers and processors are equally capable of fully supporting the World Wide Web Consortium (W3C) requirements for XSL Important To ensure that your browser remains as fully synchronized with the W3C as possible, ensure that it is kept up-to-date with the latest upgrades and enhancements from Windows Update Click Start, click All programs, and then click Windows Update to check the latest updates for your system Lesson objectives After completing this lesson, you will be able to: ! Name the component languages of XSL and state the purpose of each ! Distinguish between a style sheet based on the XSL working draft namespace and a style sheet based on the XSLT Recommendation Module 7: Formatting and Transforming: XSL and XSLT What Is XSL? ! Extensible Stylesheet Language (XSL) never achieved W3C Recommendation status ! XSL branched: " XSLT is the style sheet language " XSL-FO is the formatting language " XPath is the language for specifying locations XSL W3C Recommendations XSL-FO XSL-FO XSLT Formatting FormattingObjects Objects XSL Transformations XPath *****************************ILLEGAL FOR NON-TRAINER USE****************************** Introduction What is a style sheet? XSL is an W3C initiative to develop a programming language for creating style sheets Here are some situations where you can use style sheets: ! Suppose you have an XML source that you need to display as a table in Hypertext Markup Language (HTML) You can use a style sheet to perform this transformation ! Suppose you have an XML source that uses attributes to mark price information You are asked to combine this source with data that uses an XML vocabulary that is composed only of elements You can use a style sheet to transform the source XML by converting all attributes to elements ! One particularly important application of style sheets is to provide different output from the same data for display on different devices like mobile phones, TVs, handheld personal computers (H/PCs), and so on A style sheet is a programming tool that you use to transform or format XML A style sheet contains a set of rules that governs how transformations or formatting takes place These rules are called templates XML style sheets are expressed in well-formed XML A style sheet must use either the XSL working draft namespace or the XSLT namespace Using the XSLT namespace gives you all the functionality of an XSL namespace and provides some functionality in the newer XSLT namespace All style sheets use XPath statements to specify locations The input to a style sheet is an XML source Style sheets produce a memoryresident result set of the formatting or transformation Most often, the style sheet also contains instructions to create a stream of output, which often creates a new document The new document may be formatted as XML, HTML, XHTML, text, or some other format Module 7: Formatting and Transforming: XSL and XSLT XSL subset languages As work progressed on XSL, it became clear that the job or transforming XML would require more than a single language All further work on transforming the XML structure became XSL Transformations (XSLT) Concurrent with the work on XSLT was work on XPath XPath is now hardly identified outside of W3C documentation as being part of XSL because it has become so integral to other XML technologies But it was developed in the context of the W3C XSL initiative XSL-FO has achieved Recommendation status as of October 2001 Here is a summary of the three languages that have come out of the W3C XSL initiative Formatting and transforming XML XSL Subset Language Purpose File extensions associated with use XSLT Transform XML xsl, xml XPath Specify paths and locations in XML XPath statements not exist in standalone files XPath statements are embedded within statements belonging to other programming languages XSL-FO Express formatting semantics xsl, xml The original vision of XSL was to divide the task of language development into one part that transforms XML and another that formats XML XSLT is now the transformation language, and XSL-FO is the formatting language XSLT however, is used for both transforming and for formatting XML XSLT transforms XML by rearranging elements, sorting and searching, and performing conditional processing It formats XML for presentation in a browser or other applications by transforming XML into HTML, Extensible HTML (XHTML), or text These kinds of formatting are adequate for many jobs but when greater control over formatting must be exercised than that allowed by HTML, XSLT must yield to XSL-FO What is XSL-FO? The purpose of XSL-FO is to precisely render images, paragraph blocks, text lines, and many other graphical objects XSL-FO also provides formatting functions such as padding, font size, color, areas, and borders Module 7: Formatting and Transforming: XSL and XSLT XSL Style Sheets ! You may encounter examples of XSL working draft namespaces in style sheets ! XSL namespace is still supported by the Microsoft XML Parser (MSXML) 3.0 " MSXML 3.0 is installed by Windows XP and Internet Explorer 6.0 ! XSL is no longer supported by XML Core Services ! Current development should use XSLT Embedded XML Fragment XSL Stylesheet *****************************ILLEGAL FOR NON-TRAINER USE****************************** XSL style sheet namespace You may encounter style sheets that use the obsolete XSL working draft Uniform Resource Identifier (URI) in the namespace declaration This namespace sends a signal to the XML processor to process all elements that are prefixed by xsl: by using special functionality of the processor that transforms XML MSXML processor support for XSL and XSLT The Microsoft XML Parser (MSXML) version 3.0 still recognizes the XSL namespace as a valid way to signify a style sheet MSXML 3.0 is installed by default by the Microsoft Windows® XP operating system and by Microsoft Internet Explorer version 6.0 Therefore, for most projects, you can still use the XSL URI in a style sheet namespace declaration However, the latest version of the Microsoft XML processor, Microsoft XML Core Services (MSXML) version 4.0, does not recognize the XSL URI as a valid way to signify a style sheet Style sheets generated for new development projects should use the XSLT URI XSLT has reached W3C Recommendation status XSLT provides all of the functionality of XSL and more Module 7: Formatting and Transforming: XSL and XSLT Example In this example, an XML source contains information about pets: Moggie black Alberta Sulpher Crested Cockatoo white Max 7 The following style sheet uses the XSL working draft URI in the namespace: ... done with XSLT ! Ways in which you can use XSLT in a project that uses XML data ! The parts of an XSLT style sheet Module 7: Formatting and Transforming: XSL and XSLT What Is XSLT? ! XSLT uses... Module 7: Formatting and Transforming: XSL and XSLT 11 Parts of an XSLT Style Sheet ! Identify this as an XSLT style sheet

Ngày đăng: 10/12/2013, 16:15

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan