Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.

Slides:



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

XML: Extensible Markup Language
Dr. Alexandra I. Cristea XPath and Namespaces.
Internet Technologies1 1 Lecture 4: Programming with XSLT.
Managing Data Exchange: XPath
XPath XML Path Language. Outline XML Path Language (XPath) Data Model Description Node values XPath expressions Relative expressions Simple subset of.
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.
SDPL 2002Notes 5: XSLT1 5. Document Transformations n XSLT (W3C Rec. November 1999) –A language for transforming XML documents »representative of tree-based.
XML 6.6 XPath 6. What is XPath? XPath is a syntax used for selecting parts of an XML document The way XPath describes paths to elements is similar to.
2-Jun-15 XPath. 2 What is XPath? XPath is a syntax used for selecting parts of an XML document The way XPath describes paths to elements is similar to.
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.
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.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
SD2520 Databases using XML and JQuery
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
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.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
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
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
XSLT and XPath, by Dr. Khalil1 XSL, XSLT and XPath Dr. Awad Khalil Computer Science Department AUC.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
WORKING WITH XSLT AND XPATH
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.
Session II Chapter 2 – Chapter 2 – XSLhttp://
Sample Auto-generated XForms With XQuery Date: 1/17/2009 Dan McCreary President Dan McCreary & Associates (952) M D Metadata.
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.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
IS432: Semi-Structured Data Dr. Azeddine Chikh. 6. XML Path (XPath)
EXist Indexing Using the right index for you data Date: 9/29/2008 Dan McCreary President Dan McCreary & Associates (952) M.
Recursive Functions Creating Hierarchical Reports Date: 9/30/2008 Dan McCreary President Dan McCreary & Associates (952) M.
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
Lecture 6: XML Query Languages Thursday, January 18, 2001.
Database Systems Part VII: XML Querying Software School of Hunan University
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.
XQuery Functions Reusing XQuery Code Date: September, 2008 Dan McCreary President Dan McCreary & Associates (952) M D Metadata.
Auto-generation of Repeated Elements Part 2 of a series of XForms auto generation Date: 1/25/2008 Dan McCreary President Dan McCreary & Associates
Keyword Searching Weighted Federated Search with Key Word in Context Date: 10/2/2008 Dan McCreary President Dan McCreary & Associates
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.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
XQuery Labs Basic Reporting Date: 9/29/2008 Dan McCreary President Dan McCreary & Associates (952) M D Metadata Solutions.
IS432 Semi-Structured Data Lecture 4: XPath Dr. Gamal Al-Shorbagy.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
Martin Kruliš by Martin Kruliš (v1.1)1.
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.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
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: Extensible Markup Language
Querying and Transforming XML Data
{ XML Technologies } BY: DR. M’HAMED MATAOUI
XML in Web Technologies
XML Path Language Andy Clark 17 Apr 2002.
Sequences in XQuery Core data structure of XQuery Date: 8/25/2009
More XML XML schema, XPATH, XSLT
XML DOCUMENTS & DATABASES
XRX Diagrams Application Architecture Diagrams Date: Aug 21st, 2008
Presentation transcript:

Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D

M D Copyright 2008 Dan McCreary & Associates2 Objectives Provide a short overview of XPath Describe why knowledge of XPath is important for: –Business analysts –Project managers –Report developers –Programmers Demonstrate XPath using TEI document

M D Copyright 2008 Dan McCreary & Associates3 Definition XPath XPath: "A language for addressing parts of an XML document" Similar to a DOS or UNIX "file system path" but with powerful expressions XPath is to XML what the SQL "select" statement is to SQL XPath is not a full programming language or a query language.

M D Copyright 2008 Dan McCreary & Associates4 XPath Related Standards XSLT – XPath is used to tell XSLT how to match tags XLink – similar to HTML links but more powerful XPointer - a standard manner for identifying document fragments XQuery – a newer, more comprehensive standard that includes XPath 2.0 and allows more complex searches and data types include relational database searches. Includes clauses for "for, let, where, order-by, return"

M D Copyright 2008 Dan McCreary & Associates5 Versions Version 1.0 –W3C Recommendation November, – Version 2.0 –W3C Working Draft October, –

M D Copyright 2008 Dan McCreary & Associates6 Other Familiar Path Names DOS: –C:\Program Files\Altova\XMLSPY2004\Examples\Tutorial Web – Unix –/usr/local/lib/mylib/myprogram.jar Similarities –Absolute path starts with "/" –Relative paths express do not start with "/"

M D Copyright 2008 Dan McCreary & Associates7 XPath Has Relative Expressions self child parent ancestor sibling descendant sibling precedingfollowing ancestor following-sibling child descendant preceding-sibling

M D Copyright 2008 Dan McCreary & Associates9 Location Steps An XPath expression contains one or more "location steps", separated by slashes. Each location step has the following unabbreviated form: –axis-name :: node-test [predicate]* The abbreviated form is more commonly used, so that is what this example uses. It refers to the child axis: –node-test [predicate]*

M D Copyright 2008 Dan McCreary & Associates10 XPath Also Provides XPath has functions for manipulation of: –Nodes and sets of nodes (elements-NameTest, KindTest) –Strings (substring, contains etc.) –Numbers (position etc.) –Booleans (and/or/not etc.)

M D Copyright 2008 Dan McCreary & Associates11 Disclaimer Example was chosen for teaching purposes only Not necessarily indicative of a full actual TEI structure

M D Copyright 2008 Dan McCreary & Associates12 oXygen XPath Builder Perspective > Show View > XPath Builder

M D Copyright 2008 Dan McCreary & Associates13 Sample XML Document Foreign Relations of the United States, , Volume E-13: Documents on China, Foreign Relations of the United States Volume E-13 Documents on China, Steven E. Phillips Edward C. Keefer

M D Copyright 2008 Dan McCreary & Associates14 TEI Tree text TEI namespace teiHeader front body div type="compilation" headpb div type=“document" pb div type=“document"

M D Copyright 2008 Dan McCreary & Associates15 90/10 rule for XPath 90% of the time your XPath expressions will be very simple. They will be just getting subsets of all the data in the document They will use the default “child” selector

M D Copyright 2008 Dan McCreary & Associates16 Sample XPath Child Expressions Find the root element of any document –/ Find the root element –/TEI Find the TEI Header –/TEI/teiHeader Find the text body –/TEI/text/body Find the text body headers –/TEI/text/body/div/head Find the text body sub headers –/TEI/text/body/div/head/div/head

M D Copyright 2008 Dan McCreary & Associates17 Selecting Attributes To select an attribute you must add symbol to the expression Example: select only the divs that have an attribute type="document"

M D Copyright 2008 Dan McCreary & Associates18 Getting Data with // Get all the person names in the document –//persName Get all the dates or notes in the document –//date Get all the notes of type summary

M D Copyright 2008 Dan McCreary & Associates19 Sample Counts Count of the number of paragraphs in the document –count(//p) Count of the number of divs –count(//div) Count of the number of person names –count(//persName)

M D Copyright 2008 Dan McCreary & Associates20 What’s the Context? XPath evaluates expressions relative to a context. –Usually specified by one of the technologies that extend XPath, such as XSLT and XPointer. –Includes context node, context size, context position, etc. In XSLT, the context node is the current node being evaluated.

M D Copyright 2008 Dan McCreary & Associates21 Sample XPath Syntax Test for equality –node=‘value’ [ ] – predicate, e.g. First in sequence: [1] Last: last() * - - attributes // - all children of the context node. – context node itself.. – parent of the context node

M D Copyright 2008 Dan McCreary & Associates22 XPath String Operations concat starts-with ends-with contains substring string-length substring-before substring-after normalize-space normalize-unicode upper-case lower-case translate string-pad matches replace tokenize escape-uri

M D Copyright 2008 Dan McCreary & Associates23 Boolean Operators boolean(1 and 1) returns true (1 and 0) returns false (1 or 0) returns true (1 and 1 and (1 or 0)) returns true

M D Copyright 2008 Dan McCreary & Associates24 Contains() Returns true if the first string passed contains the second string passed Example: –//p[contains(.,'President')]

M D Copyright 2008 Dan McCreary & Associates25 Benefits of XPath Business analysts –Precise specification of constraints, support for graphical representation of rules, easy to change. Project managers –Shorten development cycle, easier to change business logic. Report developers –Pattern matching language for routing of documents based on rules, platform and language neutral. Programmers –Functions available for manipulating nodes, sets of nodes, strings, numbers, or boolean. Based on regular expressions and mathematical model. Good for mapping and transforming documents from one type to another.

M D Copyright 2008 Dan McCreary & Associates26 To Find Out More XPath 2.0 Programmer's Reference –by Michael Kay Definitive XSLT and XPath –by G. Ken Holman XSLT and XPath –John Robert Gardner and Zarella L. Rendon

M D Copyright 2008 Dan McCreary & Associates27 Thank You! Please contact me for more information: XML Development Metadata Management Services Web Services Service Oriented Architectures Business Intelligence and Data Warehouse Metadata Registries Semantic Web Dan McCreary, President Dan McCreary & Associates Metadata Strategy Development (952)