Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: XPath, NameSpaces.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

Chungnam National University DataBase System Lab
1 Quick Intro to XPath Roger L. Costello 14 December, 2012.
Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Copyright © 2003 Pearson Education, Inc. Slide 6-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: XQuery.
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: C2.
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: C3.
An Introduction to XML and Web Technologies XML Documents
VOORBLAD.
Squares and Square Root WALK. Solve each problem REVIEW:
Dr. Alexandra I. Cristea XHTML.
Dr. Alexandra I. Cristea XPath and Namespaces.
25 seconds left…...
Bottom-up Evaluation of XPath Queries Stephanie H. Li Zhiping Zou.
PSSA Preparation.
Managing Data Exchange: XPath
Team 23 Multilingual Online Dictionary 資工碩一 吳全勳 R 資工四 李竺軒 B 電機四 何 偉 B 資工二 王昱蓉 B
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.
Lecture 13. The various node tests also work on this axis: eg node() This book has descendant-or- self nodes As expected, text nodes are included in the.
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)
XPath Carissa Mills Jill Kerschbaum. What is XPath? n A language designed to be used by both XSL Transformations (XSLT) and XPointer. n Provides common.
Lecture 12. Default Processing in XSLT The default processing in XSLT is to process the XPath root node The default processing for various node types.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
XPath Tao Wan March 04, What is XPath? n A language designed to be used by XSL Transformations (XSLT), Xlink, Xpointer and XML Query. n Primary.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
XP ATH - XML Path Language. W HAT IS XP ATH ? XPath, the XML Path Language, is a query language for selecting nodes from an XML document.query languagenodesXML.
SD2520 Databases using XML and JQuery
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Navigating XML. Overview  Xpath is a non-xml syntax to be used with XSLT and Xpointer. Its purpose according to the W3.org is  to address parts of an.
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
1/17 ITApplications XML Module Session 7: Introduction to XPath.
Introduction to XPath Web Engineering, SS 2007 Tomáš Pitner.
XML DOCUMENTS & DATABASES. Summary of Introduction to XML HTML vs. XML HTML vs. XML Types of Data Types of Data Basics of XML Basics of XML XML Syntax,
CSE3201/CSE4500 Information Retrieval Systems
XPath XPath is used to navigate through elements and attributes in an XML document. XPath is a major element in W3C's XSLT standard - and XQuery and XPointer.
1 XPath XPath became a W3C Recommendation 16. November 1999 XPath is a language for finding information in an XML document XPath is used to navigate through.
XPath Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Processing of structured documents Spring 2003, Part 7 Helena Ahonen-Myka.
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
1 Displaying XML Document Web and Database Management System.
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
XPath Aug ’10 – Dec ‘10. XPath   XML Path Language   Technology that allows to select a part or parts of an XML document to process   XPath was.
Advanced Selenium.  XPath is used to navigate through elements and attributes in a document.  XPath includes over 100 built-in functions.  Functions.
WPI, MOHAMED ELTABAKH PROCESSING AND QUERYING XML 1.
XPath Presented by Kushan Athukorala. 2 Agenda XPath XPath Terminology Selecting Nodes Predicates.
Submitted To: Ms. Poonam Saini, Asst. Prof., NITTTR Submitted By: Rohit Handa ME (Modular) CSE 2011 Batch.
XPath. XPath, the XML Path Language, is a query language for selecting nodes from an XML document. The XPath language is based on a tree representation.
Session II Chapter 3 – Chapter 3 – XPath Patterns & Expressions Chapter 4 – XPath Functions Chapter 15 – XPath 2.0http://
IS432 Semi-Structured Data Lecture 4: XPath Dr. Gamal Al-Shorbagy.
CSE3201/CSE4500 XPath. 2 XPath A locator for items in XML document. XPath expression gives direction of navigation.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
1 XPath. 2 Agenda XPath Introduction XPath Nodes XPath Syntax XPath Operators XPath Q&A.
1 The XPath Language. 2 XPath Expressions Flexible notation for navigating around trees A basic technology that is widely used uniqueness and scope in.
CITA 330 Section 5 XPath. XSL XSL (Extensible Stylesheet Language) is the standard language for writing stylesheets to transform XML documents among different.
5 Copyright © 2004, Oracle. All rights reserved. Navigating XML Documents by Using XPath.
XML. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data.
XML and XPath.
{ XML Technologies } BY: DR. M’HAMED MATAOUI
XML Path Language Andy Clark 17 Apr 2002.
XPath 9-May-19.
XML DOCUMENTS & DATABASES
XPath 7-Dec-19.
Presentation transcript:

Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: XPath, NameSpaces

2 Previously we looked at: –XML Next: –XPath –Namespaces

3 XPath

4 XPath is a syntax for defining parts of an XML document XPath uses path expressions to navigate in XML documents XPath contains a library of standard functions XPath is a major element in XSLT XPath is a W3C recommendation, thus a Standard (16. November 1999 )

5 XPath Path Expressions Uses path expressions to select nodes or node-sets in an XML document. –These path expressions look very much like the expressions you see when you work with a traditional computer file system.

6 XPath Standard Functions over 100 built-in functions. –string values, –numeric values, –date and time comparison, –node and QName manipulation, –sequence manipulation, –Boolean values, –and more.

7 XPath Terminology Nodes Atomic values Items (atomic values or nodes) Relationships of nodes –Parent –Children –Siblings –Ancestors –Descendants

8 XPath Nodes 7 kinds of nodes: 1.element, 2.attribute, 3.text, 4.namespace, 5.processing-instruction, 6.comment, and 7.document (root) nodes. XML documents are treated as trees of nodes. The root of the tree is called the document node (or root node).

9 Nodes Examples Harry Potter J K. Rowling Document (root) nodeElement node Attribute node

10 Atomic values Examples* Harry Potter J K. Rowling *nodes with no children or parent

11 Selecting nodes ExpressionDescription nodenameSelects all child nodes with this name / Selects from the root node // Selects nodes in the document from the current node down that match the selection no matter where they are. Selects the current node.. Selects the parent of the current Selects attributes

12 Examples of selecting nodes Path ExpressionResult bookstoreSelects all the bookstore elements /bookstoreSelects the root element bookstore Note: If the path starts with a slash ( / ) it always represents an absolute path to an element! bookstore/bookSelects all book elements that are children of bookstore //bookSelects all book elements no matter where they are in the document bookstore//bookSelects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element all attributes that are named lang

13 Predicates Predicates are used to find a specific node or a node that contains a specific value. Predicates are always embedded in square brackets.

14 Example predicates Path ExpressionResult /bookstore/book[1]Selects the first book element that is the child of the bookstore element /bookstore/book[last()]Selects the last book element that is the child of the bookstore element /bookstore/book[last()-1]Selects the last but one book element that is the child of the bookstore element /bookstore/book[position()<3]Selects the first two book elements that are children of the bookstore element

15 Example predicates – cont. Path ExpressionResult all the title elements that have an attribute named lang all the title elements that have an attribute named lang with a value of 'eng' /bookstore/book[price>35.00] /bookstore/book[price>35.00]/title Selects all the book elements of the bookstore element that have a price element with a value greater than Selects all the title elements of the book elements of the bookstore element that have a price element with a value greater than 35.00

16 Selecting Unknown Nodes WildcardDescription *Matches any element any attribute node node()Matches any node of any kind

17 Example: selecting several paths Path ExpressionResult //book/title | //book/priceSelects all the title as well as price elements of all book elements //title | //price /bookstore/book/title | //price Selects all the title as well as price elements in the document Selects all the title elements of the book element of the bookstore element as well as all the price elements in the document

18 XPath Axes self childparent ancestordescendant ancestor-or-selfdescendant-or- self preceding-siblingfollowing-sibling precedingfollowing attribute namespace

19 axisname::nodetest[predicate] //DDD/parent::*

20 axisname::nodetest[predicate] //BBB/child::* Note: /AAA is equivalent to /child::AAA

21 More examples –Check basics, //, *, predicates, attributes, functions (new ones: count, name, normalize-space, starts- with, contains, string-length, floor, ceiling), axes, operators (mod)predicatesattributescountnamenormalize-spacestarts- withcontainsstring-lengthfloorceilingaxes operators (mod) –Note: The ancestor, descendant, following, preceding and self axes partition a document (ignoring attribute and namespace nodes): they do not overlap and together they contain all the nodes in the document. (see example)example

22 XPath Conclusion We have learned: –XPath definition –Path expressions –Standard functions –Terminology –Predicates –Location paths –Axes –Some operators

23 Before we go on, one more thing about XML: XML Namespaces

24 Naming ambiguity

25 The Idea to Solve it Assign a URI (~ URL) to every sub- language: –E.g., for XHTML 1.0: Qnames: Qualify element names with URIs: –{ Web Naming and Addressing Overview (URIs, URLs,...)

26 The actual solution Namespace declarations bind URIs to prefixes: Default namespace (no prefix) declared with: xmlns=… Lexical Scope Attribute names can also be prefixed

27 Applying namespaces

28 Next we look at how to query XML This can be done, to some extent, as we have seen, within XSLT, but the main language developed for this purpose is …