XPath node predicates. Martin Holmes

Similar documents
XSLT: where does it fit in? Martin Holmes

XPath. Lecture 36. Robb T. Koether. Wed, Apr 16, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) XPath Wed, Apr 16, / 28

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while

Informatics 1: Data & Analysis

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9

XPath Lecture 34. Robb T. Koether. Hampden-Sydney College. Wed, Apr 11, 2012

Quick XPath Guide. Introduction. What is XPath? Nodes

Notes on XML and XQuery in Relational Databases

Informatics 1: Data & Analysis

Semi-structured Data. 8 - XPath

A Data Modeling Process. Determining System Requirements. Planning the Project. Specifying Relationships. Specifying Entities

Informatics 1: Data & Analysis

Seleniet XPATH Locator QuickRef

birds fly S NP N VP V Graphs and trees

Semistructured Content

XPath. Asst. Prof. Dr. Kanda Runapongsa Saikaew Dept. of Computer Engineering Khon Kaen University

Creating joints for the NovodeX MAX exporter

An introduction to searching in oxygen using XPath

Initial Coding Guidelines

Part A: Getting started 1. Open the <oxygen/> editor (with a blue icon, not the author mode with a red icon).

Querying XML. COSC 304 Introduction to Database Systems. XML Querying. Example DTD. Example XML Document. Path Descriptions in XPath

DOM Interface subset 1/ 2

TDDD43. Theme 1.2: XML query languages. Fang Wei- Kleiner h?p:// TDDD43

XML & Databases. Tutorial. 3. XPath Queries. Universität Konstanz. Database & Information Systems Group Prof. Marc H. Scholl

accordingly. This is managed through our Other content feature.

XPath Expression Syntax

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views

Semistructured Content

Input/Output Machines

G.CO.A.2: Identifying Transformations 2

Cardinality estimation of navigational XPath expressions

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

Mouse. Mouse Action Location. Image Location

XML, DTD, and XPath. Announcements. From HTML to XML (extensible Markup Language) CPS 116 Introduction to Database Systems. Midterm has been graded

XPath and XQuery. Introduction to Databases CompSci 316 Fall 2018

CSI 3140 WWW Structures, Techniques and Standards. Representing Web Data: XML

Exercise: Editing XML in oxygen

Boardworks Ltd KS3 Mathematics. S1 Lines and Angles

Mobile App:IT. Methods & Classes

Transcript: A Day in the Life Desiree: 7 th Grade Learning Coach Profile

HAWK Language Reference Manual

Query Languages for XML

Databases and Information Systems 1. Prof. Dr. Stefan Böttcher

Comp 336/436 - Markup Languages. Fall Semester Week 9. Dr Nick Hayward

exist: An Open Source Native XML database

What if we want the child elements to calculate the offset from the boundaries of the document? CSS LAYOUT. The position Property.

Title: Recursion and Higher Order Functions

Semistructured Content

YFilter: an XML Stream Filtering Engine. Weiwei SUN University of Konstanz

Macro Programming Reference Guide. Copyright 2005 Scott Martinez

Module 201 Object Oriented Programming Lecture 11 String Arrays and Collections. Len Shand

SETTING UP NEW WINDOWS 10 DEVICE - NEW DEVICES - 1. Generally, the first question you will be asked is the Let s get Connected Page.

BDS Query. JSON Query Syntax

In the previous presentation, Erik Sintorn presented methods for practically constructing a DAG structure from a voxel data set.

Web Services Week 3. Fall Emrullah SONUÇ. Department of Computer Engineering Karabuk University

Unit 1 NOTES Honors Math 2 1

Progress Report on XQuery

Chapter 13: Bible integration

Informatics 1: Data & Analysis

6/3/2016 8:44 PM 1 of 35

Introduction to XPath

Mastering in writing xpath and css Selectors PART-1

Burrows & Langford Appendix D page 1 Learning Programming Using VISUAL BASIC.NET

(Refer Slide Time: 06:01)

Learn Ninja-Like Spreadsheet Skills with LESSON 9. Math, Step by Step

M-ary Search Tree. B-Trees. Solution: B-Trees. B-Tree: Example. B-Tree Properties. B-Trees (4.7 in Weiss)

How To Launch A Campaign On MediaTraffic

4D2b Navigating an XML Document

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1

ST. MICHAEL S CE SCHOOL

Announcements. The current topic: Scheme. Review: BST functions. Review: Representing trees in Scheme. Reminder: Lab 2 is due on Monday at 10:30 am.

XML Data Management. 5. Extracting Data from XML: XPath

Warm Up. Factor the following numbers and expressions. Multiply the following factors using either FOIL or Box Method

Navigating Input Documents Using Paths4

G.CO.B.6: Properties of Transformations 2

Algebra 2 Common Core Summer Skills Packet

jquery Tutorial for Beginners: Nothing But the Goods

An Algorithm for Streaming XPath Processing with Forward and Backward Axes

bindings (review) Topic 18 Environment Model of Evaluation bindings (review) frames (review) frames (review) frames (review) x: 10 y: #f x: 10

Trees. Carlos Moreno uwaterloo.ca EIT

Navigating an XML Document

Spatial Data Structures

XPath and XSLT. Overview. Context. Context The Basics of XPath. XPath and XSLT. Nodes Axes Expressions. Stylesheet templates Transformations

Semistructured Data and XML

Spatial Data Structures

Argos. Basic Training

WSCC Benefits and Impact on Student Learning and Health Closed Captioning

MITOCW MIT6_172_F10_lec18_300k-mp4

Chapter 2 XML, XML Schema, XSLT, and XPath

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

StreamServe Persuasion SP5 XMLIN

L A TEX Primer. Randall R. Holmes. August 17, 2018

XML/XPath Support In MySQL-5.x. Alexander Barkov Full time developer

Transcript of Abel Braaksma's Talk on XSLT Streaming at XML Prague 2014

Create a bar graph that displays the data from the frequency table in Example 1. See the examples on p Does our graph look different?

Polygons Non-Shapes. Has an area that is completely enclosed Has no extraneous lines or curves as a part of the figure.

EMERGING TECHNOLOGIES

[Video] and so on... Problems that require a function definition can be phrased as a word problem such as the following:

POLYGONS

MITOCW watch?v=kvtlwgctwn4

Transcription:

Martin Holmes

XPath Node Predicates You use paths and axes in XPath to arrive at specific nodes in your XML. You use predicates to further filter or test those nodes. Only nodes which satisfy the predicate will be selected. Predicates follow the step they apply to, and use square brackets. /TEI/text/body/div means "all the <div> nodes which are children of <body>". /TEI/text/body/div[@type='chapter'] means "only those <div> nodes which are children of <body> and also have a type attribute with the value "chapter" ". XPath Predicates: some examples //div[head] = all <div> nodes which have a direct child <head> element. //div[contains(head,"scene")] = all <div> nodes which have a direct child <head> element which contains the text "Scene". //div[1] = all <div> nodes which are the first <div> node in their parent element. //div[position() = last()] = all <div> nodes which are the last <div> node in their parent element. XPath Predicates: Tasks (1) Using the places.xml file here: http://web.uvic.ca/~mholmes/dhoxss2013/examples/ places.xml and the XPath console in oxygen, find the following information: 2

How many place entries are mapped as polygons? (Hint: a polygon location has more than 2 <geo> elements.) How many are single points? How many place entries contain external links (<ref type="external">)? XPath Predicates: Tasks (1) answers Using the places.xml file, and the XPath console in oxygen, find the following information: Q: How many place entries are mapped as polygons? (Hint: a polygon location has more than 2 <geo> elements.) A: 77 count(//place[count(location/geo) gt 2]) Q: How many are single points? A: 110 count(//place[count(location/geo) eq 1]) Q: How many place entries contain external links (<ref type="external">)? A: 105 count(//place[descendant::ref[@type='external']]) (Note the nested predicates!) XPath Predicates can be chained The following examples work on the Hamlet XML file here: http://web.uvic.ca/~mholmes/ dhoxss2013/examples/hamlet.xml //div[parent::div][count(descendant::l) gt 200] = all scenes containing more than 200 lines. //div[parent::div][descendant::sp/@who='#horatio'] = all scenes in which Horatio speaks. 3

//sp[position()=last()][@who='#hamlet'] = speeches by Hamlet which are the last speeches in their scene. Supplementary question: how would you find the last speech in the whole play? Hint: you could use the following:: axis and the not() function, or you could use a long path with several instances of position()=last(). The Hamlet file actually has lots of <ab> elements in speeches as well as <l> elements, so this line count stuff is not a true reflection of the length of speeches. It might be worth telling the students there's something wrong with it, and asking them to look at the XML source to see if they can figure out what it is. Then you could amend the first item in this slide, and some of the ones in the next slide, to account for this. XPath Predicates can be nested //div[child::div][descendant::sp[@who='#ophelia']] = all acts in which Ophelia speaks. //div[parent::div][count(descendant::sp[@who = '#Hamlet']) gt 30] = all scenes in which Hamlet has more than 30 speeches. //sp[descendant::l[descendant::stage]] = all speeches which contain lines which contain stage directions XPath Predicates: Tasks (2) Using the places.xml file, and the XPath console in <oxygen/>, find the following information: How many place entries mention the name whose @key value is "kellett"? How many place entries have a bibliography with more than two items? How many place entries which are single points contain external links? 4

XPath Predicates: Tasks (2) answer 1 How many place entries mention the name whose @key value is "kellett"? count(//place[descendant::name[@key='kellett']]) (The answer is 9.) XPath Predicates: Tasks (2) answer 2 How many place entries have a bibliography with more than two items? count(//place[count(descendant::bibl[parent::listbibl]) gt 2]) (The answer is 12.) Note: if we omit the [parent::listbibl] predicate, we will be counting bibl elements which appear outside the bibliography list, in the body of the explanatory text. XPath Predicates: Tasks (2) answer 3 How many place entries which are single points contain external links? count(//place[descendant::ref[@type='external']][count(./location/geo) = 1]) (The answer is 58.) Predicates filter the results of an XPath. They follow the step they apply to. They're enclosed in square brackets. They can be chained. They can be nested. XPath predicates: summary 5