1 / 8

W3C

Get title of books published by Addison-Wesley after 1993. ... Get titles of books published after 1994, but. NOT published by Addison-Wesley. Order the ...

Kelvin_Ajay
Download Presentation

W3C

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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. XML(eXtensible Markup Language) <bib> <book year="1994"> <title>TCP/IP Illustrated</title> <author> <last>Stevens</last> <first>W.</first> </author> <publisher>Addison Wesley</publisher> <price>65.95</price> </book> <book year="1992"> <title> … … </bib>

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

  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 – 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 doc("XMP/bib.xml")/bib/book let $c := $b/publisher where $c != "Addison-Wesley" and $b/@year > 1994 order by $b/title descending return $b/title <title>The Economics of Technology and Content of Digital TV</title><title>Data on the Web</title>

  6. XQuery – Example 3 Join <bib> and <reviews> on <title> and print the title and price. for $b in doc("XMP/bib.xml")/bib/book, $e in doc("XMP/reviews.xml")/reviews/entry where $e/title = $b/title return <titlelist> { $b/title, $e/price } </titlelist> <titlelist> <title>TCP/IP Illustrated</title> <price>65.95</price> </titlelist>

  7. XQuery – Example 4 Get the average price of the books. <results>{ let $prices := doc("XMP/bib.xml")/bib/book/price return <avgprice>{ avg($prices) }</avgprice> }</results> <results> <avgprice>75.45</avgprice> </results>

  8. 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 doc("XMP/bib.xml")/bib/book, $c in $b[publisher = "Addison-Wesley"] return <book> { $c/@year } { $c/title } </book> <book year="1994"> <title>TCP/IP Illustrated</title> </book><book year="1992"> <title>Advanced Programming in the Unix environment</title> </book>

More Related