Use Bookstore data from early XML videos
Get all book titles
doc(“BookstoreQ.xml”) /Bookstore/Book/Title
output is XML
Get all book or magazine titles
doc(“BookstoreQ.xml”) /Bookstore/(Book | Magazine)/Title
output is XML
Get all titles
doc(“BookstoreQ.xml”) /Bookstore/*/Title
output is XML
Get all titles
doc(“BookstoreQ.xml”) //Title
output is XML
Every element + subelements at every level of the tree
doc(“BookstoreQ.xml”) //*
output is XML
Get all book ISBNs
doc(“BookstoreQ.xml”) /Bookstore/Book/data(@ISBN)
output is in strings
Get all books costing less than $90
doc(“BookstoreQ.xml”) /Bookstore/Book[@Price < 90]
outputs XML - all book data
Get all books costing less than $90
doc("BookstoreQ.xml") /Bookstore/Book[@Price < 90]/Title
output is XML, just book titles
Titles of books containing a remark
doc("BookstoreQ.xml") /Bookstore/Book[Remark]/Title
outputs XML
Titles of books costing less than $90 where "Ullman" is an author
doc("BookstoreQ.xml") /Bookstore/Book[@Price < 90 and Authors/Author/Last_Name = "Ullman"]/Title
outputs XML
Titles of books costing less than $90 where Jeffrey Ullman is an author
doc("BookstoreQ.xml") /Bookstore/Book[@Price < 90 and Authors/Author[Last_Name = "Ullman" and First_Name = "Jeffrey"]]/Title
outputs XML
no slash before conditions
conditions within conditions
All second authors
doc("BookstoreQ.xml") //Authors/Author[2]
output is XML
Titles of books with a remark containing "great"
doc("BookstoreQ.xml") //Book[contains(Remark, "great")]/Title
output is XML
All magazines where there's a book with the same title
doc("BookstoreQ.xml") //Magazine[Title = doc("BookstoreQ.xml") //Book/Title]
output is XML
All elements whose parent is not "Bookstore" or "Book"
doc("BookstoreQ.xml") /Bookstore//*[name(parent::*) != "Bookstore" and name(parent::*) != "Book"]
output is XML
All books and magazines with non-unique titles
doc("BookstoreQ.xml") /Bookstore/(Book | Magazine) [Title = following-sibling::*/Title or Title = preceding-sibling::*/Title]
output is XML
All books or magazines with the same title as another book
doc("BookstoreQ.xml") /Bookstore/(Book | Magazine) [Title = following-sibling::Book/Title or Title = preceding-sibling::Book/Title]
output is XML
Books where every author's first name includes "J"
doc("BookstoreQ.xml") //Book[count (Authors/Author[contains(First_Name, "J")]) = count (Authors/Author/First_Name)]
output is XML
Find all books where Ullman is an author, and Widom is not an author
doc("BookstoreQ.xml") /Bookstore/Book[Authors/Author/Last_Name = "Ullman" and count(Authors/Author[Last_Name = "Widom]) = 0]/Title
output is XML
implicit existential quantification vs universal quantification