2001 Prentice Hall, Inc. All rights reserved. Chapter 11 – XML Path Language (XPath) Outline 11.1Introduction 11.2Nodes 11.3Location Paths Axes Node Tests Location Paths Using Axes and Node Tests 11.4Node-set Operators and Functions 11.5Internet and World Wide Web Resources
2001 Prentice Hall, Inc. All rights reserved. Outline Fig. 11.1Simple XML document <![CDATA[ // C++ comment 12 if ( this->getX() < 5 && value[ 0 ] != 3 ) 13 cerr displayError(); 14 ]]> C++ How to Program by Deitel & Deitel 18
2001 Prentice Hall, Inc. All rights reserved. Fig. 11.2XPath tree for Fig Root Comment Fig : 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
2001 Prentice Hall, Inc. All rights reserved. Outline Fig. 11.3XML document with processing-instruction and namespace nodes Processing Instruction and Namespace Nodes <deitel:book deitel:edition = "1" 17 xmlns:deitel = " 18 XML How to Program
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 : simple2.xml Element head Namespace Continued… Fig. 11.4Tree diagram of an XML document with a processing-instruction node
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 Element title Text XML Hot to Program …Continued
2001 Prentice Hall, Inc. All rights reserved. Fig. 11.5XPath node types
2001 Prentice Hall, Inc. All rights reserved. Fig. 11.5XPath node types. (Part 2)
2001 Prentice Hall, Inc. All rights reserved. Fig. 11.6XPath axes.
2001 Prentice Hall, Inc. All rights reserved. Fig. 11.7Some XPath node tests.
2001 Prentice Hall, Inc. All rights reserved. Fig. 11.8Some location-path abbreviations.
2001 Prentice Hall, Inc. All rights reserved. Outline Fig. 11.9XML document that marks up book translations Java How to Program 10 Spanish 11 Chinese 12 Japanese 13 French 14 Japanese C++ How to Program 19 Korean 20 French 21 Spanish 22 Italian 23 Japanese
2001 Prentice Hall, Inc. All rights reserved. Output for Fig. 11.9
2001 Prentice Hall, Inc. All rights reserved. Fig 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…
2001 Prentice Hall, Inc. All rights reserved. Fig XPath tree for books.xml Attribute edition 2 Text French Text Japanese Element translation Continued… Other nodes…
2001 Prentice Hall, Inc. All rights reserved. Fig Node-set operators.
2001 Prentice Hall, Inc. All rights reserved. Fig Some node-set functions.
2001 Prentice Hall, Inc. All rights reserved. Outline Fig List of companies with stock symbols Intel Corporation Cisco Systems, Inc Dell Computer Corporation Microsoft Corporation Sun Microsystems, Inc CMGI, Inc
2001 Prentice Hall, Inc. All rights reserved. Outline Fig Demonstrating some String functions <xsl:stylesheet version = "1.0" 7 xmlns:xsl = " <xsl:if test = 17 'C')"> <xsl:value-of select = 21 - ', name)"/>
2001 Prentice Hall, Inc. All rights reserved. Outline Output for Fig