1993 return $b/title TCP/IP Illustrated"> 1993 return $b/title TCP/IP Illustrated">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

XQuery: 1 W3C (World Wide Web Consortium) What is W3C? –An industry consortium, best known for standardizing HTML and XML. –Working Groups create or adopt.

Similar presentations


Presentation on theme: "XQuery: 1 W3C (World Wide Web Consortium) What is W3C? –An industry consortium, best known for standardizing HTML and XML. –Working Groups create or adopt."— Presentation transcript:

1 XQuery: 1 W3C (World Wide Web Consortium) What is W3C? –An industry consortium, best known for standardizing HTML and XML. –Working Groups create or adopt new “recommendations” www.w3.org

2 XQuery: 2 XML (eXtensible Markup Language) TCP/IP Illustrated Stevens W. Addison Wesley 65.95 …

3 XQuery: 3 XQuery – Example 1 Get title of books published by Addison-Wesley after 1993. for $b in $bib/book where $b/publisher = "Addison-Wesley" and $b/@year > 1993 return $b/title TCP/IP Illustrated

4 XQuery: 4 FLWOR Expressions Basic FLWOR Expression: –For – consider (introduce a variable) –Let – introduce additional variables –Where – filter by conditions –Order by – order the output –Return – build results Xquery is compositional: any place XML data can go, another { FLWOR } expression can go.

5 XQuery: 5 XQuery – Example 2 Get titles of books published after 1994, but NOT published by Addison-Wesley. Order the result in descending order by title. for $b in $bib/book let $c := $b/publisher where $c != "Addison-Wesley" and $b/@year > 1994 order by $b/title descending return $b/title The Economics of Technology and Content for Digital TV Early Adopter XQuery Data on the Web

6 XQuery: 6 XQuery – Example 3 Join and on and print the title and price. for $b in $bib/book, $e in $reviews/entry where $e/title = $b/title return { $b/title, $e/price } TCP/IP Illustrated 65.95 Advanced Programming in the Unix environment 65.95 Data on the Web 34.95

7 XQuery: 7 XQuery – Example 4 Get the average price of the books. { let $prices := $bib/book/price return { avg($prices) } } Should be: 75.45 Actually is: type error: no common aggregate type because price is declared to be of type string

8 XQuery: 8 XQuery – Example 4 (continued) Get the average of the years of the books. { let $years := $bib/book/@year return { avg($years) } } 1997.4

9 XQuery: 9 XQuery – Example 5 Get year (as an attribute) and title of book. (Use a predicate to limit the books to those published by Addison-Wesley.) for $b in $bib/book, $c in $b[publisher = "Addison-Wesley"] return { $c/@year } { $c/title } TCP/IP Illustrated Advanced Programming in the Unix environment


Download ppt "XQuery: 1 W3C (World Wide Web Consortium) What is W3C? –An industry consortium, best known for standardizing HTML and XML. –Working Groups create or adopt."

Similar presentations


Ads by Google