1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Module 6: Using XPath to Navigate a Tree of Nodes ppt

46 544 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 46
Dung lượng 0,96 MB

Nội dung

Contents Overview 1 Lesson: What Is XPath? 2 Lesson: Using XPath 11 Lesson: The Range of Application of XPath 21 Lab 6: Using XPath to Navigate and Select Data 27 Review 37 Module 6: Using XPath to Navigate a Tree of Nodes 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 6: Using XPath to Navigate a Tree of Nodes iii Instructor Notes This module provides participants with an introduction to Extensible Markup Language Path Language (XPath). This module is not an in-depth technical module. Rather, it is designed to give an overview of the breadth of XPath capabilities and enough technical examples to illustrate why XPath is a very important part of the Extensible Markup Language (XML) technology set. Participants can learn more through other courses and by reading books and the XML and Extensible Stylesheet Language (XSL) Web page on Microsoft ® MSDN ® at http://msdn.microsoft.com/xml. Be prepared to answer many questions about this module, because the topic can be confusing. After completing this module, participants will be able to: ! Identify XPath expressions that are embedded in code and other places. ! Identify the proper situations where you can use XPath. ! Identify solutions where XPath is a necessary requirement or a critical enabling technology. ! Use XPath to navigate several documents and retrieve content from them according to XPath characteristics. ! Begin using XPath to navigate XML documents and select content in XML documents. ! Describe how it can be used by other XML technologies. Presentation: 45 minutes Lab: 30 minutes iv Module 6: Using XPath to Navigate a Tree of Nodes Materials and Preparation This section provides the materials and preparation tasks that you need to teach this module. To teach this module, you need the following materials: • Microsoft PowerPoint ® file 2500A_06.ppt XPath is complex topic and requires some serious preparation to cover it comfortably. To prepare for this module: ! Read all of the materials for this module. ! Review the references to XPath in the modules for XQuery, XSL Transformations (XSLT), the Document Object Model (DOM), and SQL XML. ! Read the sections on XML in Microsoft SQL Server ™ 2000 Books Online. ! Complete the lab and the practice. ! Read the sections of the World Wide Web Consortium (W3C) site on XPath, XML Pointer Language (XPointer), XML Linking Language (Xlink), and XQuery. Read the relevant Recommendation papers and Use Case papers if you have time. There is a lot of information on this site, so you will need to be selective. Check this site on a regular basis so that you are not surprised by the questions of participants who do check it regularly. ! Attend Course 1913A, Exchanging and Transforming Data Using XML and XSLT, before teaching this course. In particular, be thoroughly comfortable with Module 2 on XPath. ! Work through as many examples of XPath expressions and uses of XPath as you can so that you can give participants additional ideas about the uses of XPath. To understand XPath, participants will need good verbal and visual examples, so be ready to diagram XPath examples if required to clarify the concepts. Required Materials Preparation Tasks Module 6: Using XPath to Navigate a Tree of Nodes v Instructor Setup for a Lab This section provides setup instructions that are required to prepare the instructor computer or classroom configuration for a lab. ! Prepare for the lab 1. Be sure that SQL Server 2000 XML support in Internet Information Services (IIS) is set up and working properly. 2. Be sure that the lab files are available. Lab 6: Using XPath to Navigate and Select Data vi Module 6: Using XPath to Navigate a Tree of Nodes Module Strategy This module is a preview of some of the content in subsequent modules on XSLT, XQuery, and SQL XML. Be prepared to offer short description of the functionality of XQuery, XSLT, and SQL XML. Be prepared to say how XPath is used in each. Use the following strategy to present this module: ! What Is XPath? This lesson introduces XPath and the reasons that you need it. To understand the rest of the module, the participants must understand the nature of XPath as a navigational language for XML documents. Stress that XPath is an XML language that provides access to nodes and their contents wherever the nodes are in an XML document. The role of W3C in the development of XPath in conjunction with the development of XQuery illustrates the dynamic nature of XML technologies and languages. Stress that this evolution is ongoing and requires continual adjustments and refinements by both vendors and developers. However, stress that the development is not random. ! Using XPath This topic describes the many facets of XPath. Concentrate on location paths, node-sets, and the examples used to illustrate the nature of these navigational techniques. Teach the complexity of XPath expressions carefully. It is easy to overwhelm participants with the axis::node-set[predicate] notation. Although this notation is concise, XPath is not the friendliest of navigational languages. The remainder of the module covers the broad range of additional operators and functions that are available for use with XPath expressions. While these are likely to be familiar to participants, they might find their role in XPath more difficult to understand than their role in other languages, such as SQL. Use the examples provided, and be prepared to provide additional examples if participants are having trouble with these concepts. Refer participants to Module 2 of Course 1913A, Exchanging and Transforming Data Using XML and XSLT. This course provides a detailed treatment of the XSLT. Module 6: Using XPath to Navigate a Tree of Nodes vii ! XPath and Other Technologies The module started with the general need for XPath. The module concludes with a return to that theme but in a more particular way. Each of the XML technologies listed illustrates an area where XPath is needed for proper navigation and manipulation of XML data documents. Be prepared with extra examples for each technology listed if you have time. The more you can do with extra material, the better your class will understand the nature of XPath. Many people can understand XPath in the abstract but have trouble with the concrete activity of creating and using specific XPath expressions. Use the practice to emphasize the way node navigation works with all of these technologies. Be sure not to rush this practice, because it can easily confuse those new to these concepts and technologies. Also, be sure to make yourself familiar with the examples, structure, and function of the practice files. Use the practice to emphasize that the power of XML comes from combining technologies rather than from using any single technology by itself. Module 6: Using XPath to Navigate a Tree of Nodes 1 Overview ! What Is XPath? ! Using XPath ! The Range of Application of XPath ***************************** ILLEGAL FOR NON - TRAINER USE ****************************** In this module, you will gain an understanding of XML Path Language (XPath) and how you can use XPath to locate parts of Extensible Markup Language (XML) documents and navigate through a document that is represented as a tree of nodes. After completing this module, you will be able to: ! Identify XPath expressions that are embedded in code and other places. ! Identify proper situations where you can use XPath. ! Identify solutions where XPath is a necessary requirement or a critical enabling technology. ! Use XPath to navigate several documents and retrieve content from them according to XPath characteristics. ! Begin using XPath to navigate XML documents and select content in XML documents. ! Describe how it can be used by other XML technologies. Introduction Objectives 2 Module 6: Using XPath to Navigate a Tree of Nodes Lesson: What Is XPath? ! A Language for Document Addressing ! What Are the Node Types in XPath? ! What Is a Location Path? ! Location Path Syntax ***************************** ILLEGAL FOR NON - TRAINER USE ****************************** Some of the functionality of XPath is similar to the functionality of the Document Object Model (DOM). For example, by using DOM, you can locate a certain piece of XML data by node type. However, the use of XPath, for specifying location information in an XML document, is far more pervasive than the use of DOM. What then is XPath, and why is it the technology of choice for querying XML? After completing this lesson, you will be able to: ! Define XPath. ! State why you need XPath to work with XML documents. ! Define a location path. ! Explain location path syntax. ! Choose between using unabbreviated and abbreviated XPath syntax. Introduction Lesson ob jectives [...]... 4 Module 6: Using XPath to Navigate a Tree of Nodes Pattern matching To find parts of XML documents, you must be able to look for patterns of information in both data and metadata XML Pointer Language (XPointer), Extensible Stylesheet Language Transformations (XSLT), and XQuery depend on the pattern matching capabilities of XPath One form of pattern matching is based on finding certain node characteristics,... that a colleague thinks that, because applications are never written solely by using XPath, it is probably not worth learning What can you say about whether XPath is worth learning more about? 5 A manager tells your Web application team is told that a purchase order from a client must be transformed before it can be used What do you use to achieve this? Module 6: Using XPath to Navigate a Tree of Nodes. .. can use XPath to extract from an XML source whatever pattern of content or XML structure you are interested in Navigation XPath allows you to navigate through the nodes of an XML source You can combine XPath navigation with other programming techniques For example, you develop an application that uses DOM to load an XML document into memory, XPath to navigate and select nodes, and then DOM again to. .. Understand how to write a basic location path ! Recognize XPath operators and functions ! Recognize XPath conditional expressions ! Identify the basic uses of XPath in DOM functions ! Identify the basic requirements and uses of XPath 12 Module 6: Using XPath to Navigate a Tree of Nodes How to Construct a Location Path 1 Analyze the XML source to be used 2 Define your search criteria 3 Determine what to. .. answers to frequently asked questions about XPath Question Answer Who developed XPath? TheW3C developed XPath What’s the current state of W3C XPath activity? XPath version 2 is currently under development How do you use XPath? You use XPath to provide a way for your application to navigate from one node to the next, performing operations along the way XPath also provides a way to address patterns of. .. string-length(employee/fullname) Returns the string length of the child element 18 Module 6: Using XPath to Navigate a Tree of Nodes Precedence XPath also provides for precedence, as shown in the following table Example Description [] Filters () Grouping // / Path operators < = > Comparisons = != Comparisons | Union not() Boolean not and Boolean and or Boolean or Module 6: Using XPath to Navigate a Tree of Nodes. .. You are asked to build a system that allows you to do URL queries against a data store You are told that the data store is SQL Server 2000 2 A manager asks you to combine several XML documents for further processing in your application 3 An XML data document needs to be loaded into a document tree for processing The details of the nodes need to be manipulated and presented to the user in a message... Names and namespaces, for example, label:categoryname or @label:code The comment function The processing-instructions function The predicate applies an additional filter to the data For example you can filter by position, by value, or by presence Module 6: Using XPath to Navigate a Tree of Nodes Relative or absolute location paths Location paths can be absolute or relative An absolute location path... expression applies The axes provide a coordinate system for expressions Axes specify location information within an XML source Functions and variables Function and variable types in XPath are similar to those of other programming languages Location path A location path is a special form of XPath expression whose purpose is to specify path information Although XPath is capable of much greater functionality,... scope of the XPath statement Syntax of a location step A single location step is composed of three parts: an axis reference, a node-test, and a predicate A location path is composed of one or more location steps axis::node-test[predicate]… XPath defines 13 different types of axes Each axis provides you with a different way to navigate the XPath node-set The node test is the pattern that XPath matches . What Is XPath? 2 Lesson: Using XPath 11 Lesson: The Range of Application of XPath 21 Lab 6: Using XPath to Navigate and Select Data 27 Review 37 Module 6:. by itself. Module 6: Using XPath to Navigate a Tree of Nodes 1 Overview ! What Is XPath? ! Using XPath ! The Range of Application of XPath *****************************

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

TỪ KHÓA LIÊN QUAN