|
NOTE:
These slides have not been updated since 2003. They have been superseded by the book
Anders Møller and Michael Schwartzbach, February 2006 |
|
| THE XML REVOLUTION - TECHNOLOGIES FOR THE FUTURE WEB |
|
"The titles of all recipes":
for $t in document("recipes.xml")//title
return $t
|
<title>Beef Parmesan with Garlic Angel Hair Pasta</title>, <title>Ricotta Pie</title>, <title>Linguine Pescadoro</title>, <title>Zuppa Inglese</title>, <title>Cailles en Sarcophages</title> |
"The dishes that contain flour":
<floury>
{ for $r in document("recipes.xml")//recipe[.//ingredient[@name="flour"]]
return <dish>{$r/title/text()}</dish>
}
</floury>
|
<floury> <dish>Ricotta Pie</dish> <dish>Zuppa Inglese</dish> <dish>Cailles en Sarcophages</dish> </floury> |
"For each ingredient, the recipes that it is used in":
for $i in distinct-values(document("recipes.xml")//ingredient/@name)
return <ingredient name="{$i}">
{ for $r in document("recipes.xml")//recipe
where $r//ingredient[@name=$i]
return $r/title
}
</ingredient>
|
<ingredient name="beef cube steak"> <title>Beef Parmesan with Garlic Angel Hair Pasta</title> </ingredient>, <ingredient name="onion, sliced into thin rings"> <title>Beef Parmesan with Garlic Angel Hair Pasta</title> </ingredient>, ... <ingredient name="butter"> <title>Beef Parmesan with Garlic Angel Hair Pasta</title> <title>Cailles en Sarcophages</title> </ingredient>, ... |
"The recipes that use some of the stuff in our refrigerator":
distinct-values(
for $r in document("recipes.xml")//recipe
for $i in $r//ingredient/@name
for $j in document("fridge.xml")//stuff[text()=$i]
return $r/title
)
|
<title>Beef Parmesan with Garlic Angel Hair Pasta</title>, <title>Ricotta Pie</title>, <title>Linguine Pescadoro</title>, |
|
| COPYRIGHT © 2000-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH |
|