Presentation is loading. Please wait.

Presentation is loading. Please wait.

 2001 Prentice Hall, Inc. All rights reserved. Chapter 11 – XML Path Language (XPath) Outline 11.1Introduction 11.2Nodes 11.3Location Paths 11.3.1Axes.

Similar presentations


Presentation on theme: " 2001 Prentice Hall, Inc. All rights reserved. Chapter 11 – XML Path Language (XPath) Outline 11.1Introduction 11.2Nodes 11.3Location Paths 11.3.1Axes."— Presentation transcript:

1  2001 Prentice Hall, Inc. All rights reserved. Chapter 11 – XML Path Language (XPath) Outline 11.1Introduction 11.2Nodes 11.3Location Paths 11.3.1Axes 11.3.2Node Tests 11.3.3Location Paths Using Axes and Node Tests 11.4Node-set Operators and Functions 11.5Internet and World Wide Web Resources

2  2001 Prentice Hall, Inc. All rights reserved. Outline Fig. 11.1Simple XML document. 1 2 3 4 5 6 7 8 9 <![CDATA[ 10 11 // C++ comment 12 if ( this->getX() < 5 && value[ 0 ] != 3 ) 13 cerr displayError(); 14 ]]> 15 16 17 C++ How to Program by Deitel & Deitel 18

3  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.2XPath tree for Fig. 11.1. Root Comment Fig. 11.1 : simple.xml Comment Simple XML document Element book Attribute Title C++ How to Program Attribute edition 3 Element sample Text // C++ comment if (this -> getX() displayError(); Text C++ How to Program by Deitel & Deitel

4  2001 Prentice Hall, Inc. All rights reserved. Outline Fig. 11.3XML document with processing-instruction and namespace nodes. 1 2 3 4 5 6 7 8 9 Processing Instruction and Namespace Nodes 10 11 12 13 14 15 16 <deitel:book deitel:edition = "1" 17 xmlns:deitel = "http://www.deitel.com/xmlhtp1"> 18 XML How to Program 19 20 21 22 23

5  2001 Prentice Hall, Inc. All rights reserved. Root Comment Processing instructions and namespaces Element html Element title Text Processing instructions and Namespcae Nodes Comment Fig. 11.3 : simple2.xml Element head Namespace http://www.w3.org/TR/REC-html40 Continued… Fig. 11.4Tree diagram of an XML document with a processing-instruction node

6  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.4Tree diagram of an XML document with a processing-instruction node. (Part 2) Processing Instruction deitelprocessor example = “fig11_03.xml” Element body Element book Attribute edition 1 Namespace http://www.deitel.com/xmlhtp1 Element title Text XML Hot to Program …Continued

7  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.5XPath node types

8  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.5XPath node types. (Part 2)

9  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.6XPath axes.

10  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.7Some XPath node tests.

11  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.8Some location-path abbreviations.

12  2001 Prentice Hall, Inc. All rights reserved. Outline Fig. 11.9XML document that marks up book translations. 1 2 3 4 5 6 7 8 9 Java How to Program 10 Spanish 11 Chinese 12 Japanese 13 French 14 Japanese 15 16 17 18 C++ How to Program 19 Korean 20 French 21 Spanish 22 Italian 23 Japanese 24 25 26

13  2001 Prentice Hall, Inc. All rights reserved. Output for Fig. 11.9

14  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.10 XPath tree for books.xml Element BOOK Element title Element translation Text Spanish Element translation Text Java How to Program Element translation Attribute edition 1 Text Chinese Attribute edition 1 Text Japanese Other nodes… Continued…

15  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.10 XPath tree for books.xml Attribute edition 2 Text French Text Japanese Element translation Continued… Other nodes…

16  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.11Node-set operators.

17  2001 Prentice Hall, Inc. All rights reserved. Fig. 11.12Some node-set functions.

18  2001 Prentice Hall, Inc. All rights reserved. Outline Fig. 11.13List of companies with stock symbols. 1 2 3 4 5 6 7 8 9 Intel Corporation 10 11 12 13 Cisco Systems, Inc. 14 15 16 17 Dell Computer Corporation 18 19 20 21 Microsoft Corporation 22 23 24 25 Sun Microsystems, Inc. 26 27 28 29 CMGI, Inc. 30 31 32

19  2001 Prentice Hall, Inc. All rights reserved. Outline Fig. 11.14 Demonstrating some String functions. 1 2 3 4 5 6<xsl:stylesheet version = "1.0" 7 xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> 8 9 10 11 12 13 14 15 16 <xsl:if test = 17 "starts-with(@symbol, 'C')"> 18 19 20 <xsl:value-of select = 21 "concat(@symbol,' - ', name)"/> 22 23 24 25 26 27 28 29 30

20  2001 Prentice Hall, Inc. All rights reserved. Outline Output for Fig. 11.14


Download ppt " 2001 Prentice Hall, Inc. All rights reserved. Chapter 11 – XML Path Language (XPath) Outline 11.1Introduction 11.2Nodes 11.3Location Paths 11.3.1Axes."

Similar presentations


Ads by Google