Download
slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Sheet 8 PowerPoint Presentation

Sheet 8

166 Vues Download Presentation
Télécharger la présentation

Sheet 8

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Sheet 8 XQuery

  2. Organization • Exam will be on Tue. 17.07.2007 from 10-12 • Room TBA • Please register via email • I will post old exams

  3. xquery version "1.0"; //flight[@to = "Rom"] xquery version "1.0"; for $flight in //flight where $flight[@to = "Rom"] order by $flight/@start ascending return $flight

  4. xquery version "1.0"; let $flights:=//flight for $to in $flights[@to ="Rom"], $from in $flights[@from ="Baden-Baden"] where $to/@from eq $from/@to return <flights> { <from>{$from}</from>, <to>{$to}</to> } </flights>

  5. xquery version "1.0"; declare namespace f= "http://www.cgnm.de/xml/xquery/functions"; declare function f:search($des as xs:string, $dep as xs:string) { for $a in //flight where $a/@to = $des return if(data($a/@from)=$dep) then <start>{$a}</start> <transits>{ <transit>{$a }</transit>,f:search(data($a/@from), $dep) }</transits> }; <html> {f:search("Rom", "Baden-Baden")} </html>

  6. Validating & Static Type checking • Confer slides 28-31 • Validating: • Output doc check by normal validation • Output doc check by some test examples • Done at runtime

  7. Static Type Checking • Done at query compile time • Use validate expressions

  8. <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT uni (student+, session+)> <!ELEMENT student (name, take+)> <!ELEMENT take (grade)> <!ATTLIST takeIDREF #REQUIRED > <!ELEMENT session (courseno,semester,instructor) > <!ATTLIST session sessionNo ID #REQUIRED > <!ELEMENT name (#PCDATA)> <!ELEMENT courseno (#PCDATA)> <!ELEMENT semester (#PCDATA)> <!ELEMENT instructor (#PCDATA)> <!ELEMENT grade (#PCDATA)>