L10 - XPath and XQuery CS174A XPath& XQuery 2 XPath and...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: XPath and XQuery CS174A: XPath & XQuery 2 XPath and XQuery ¡ XPath is a language for describing paths in XML documents – Really think of the semi-structured data graph and its paths ¡ XQuery is a full query language for XML documents with power similar to OQL CS174A: XPath & XQuery 3 Example DTD 〈 !DOCTYPE Bars [ 〈 !ELEMENT BARS (BAR ∗ , BEER ∗ ) 〉 〈 !ELEMENT BAR ( PRICE +)〉 〈 !ATTLIST BAR name = ID 〉 〈 !ELEMENT PRICE (# PCDATA )〉 〈 !ATTLIST PRICE theBeer = IDREF 〉 〈! ELEMENT BEER ()〉 〈 !ATTLIST BEER name = ID , soldBy = IDREFS 〉 ]〉 CS174A: XPath & XQuery 4 Example Document 〈 BARS 〉 〈 BAR name = “JoesBar” 〉 〈 PRICE theBeer = “Bud” 〉2.50〈 /PRICE 〉 〈 PRICE theBeer = “Miller” 〉3.00〈 /PRICE 〉 〈 /BAR 〉 … 〈 BEER name = “Bud” , soldBy = “JoesBar, SuesBar,…” 〉 〈 /BEER 〉 … 〈 /BARS 〉 CS174A: XPath & XQuery 5 Path Descriptors ¡ Simple path descriptors are sequences of tags separated by slashes ( / ) ¡ If the descriptor begins with / , then the path starts at the root and has those tags, in order ¡ If the descriptor begins with // , then the path can start anywhere CS174A: XPath & XQuery 6 ¡ / BARS / BAR / PRICE describes the set with these two PRICE objects as well as the PRICE objects for any other bars Example: / BARS / BAR / PRICE 〈 BARS 〉 〈 BAR name = “JoesBar” 〉 〈 PRICE theBeer = “Bud” 〉2.50〈 /PRICE 〉 〈 PRICE theBeer = “Miller” 〉3.00〈 /PRICE 〉 〈 /BAR 〉 … 〈 BEER name = “Bud” , soldBy = “JoesBar, SuesBar,…” 〉 〈 /BEER 〉 … 〈 /BARS 〉 CS174A: XPath & XQuery 7 ¡ // PRICE describes the same PRICE objects, but only because the DTD forces every PRICE to appear within a BARS and a BAR Example: // PRICE 〈 BARS 〉 〈 BAR name...
View Full Document

This note was uploaded on 05/02/2010 for the course CS 174a taught by Professor Zhin during the Fall '09 term at UCSB.

Page1 / 26

L10 - XPath and XQuery CS174A XPath& XQuery 2 XPath and...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online