Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML Data Management XPath Exercises: Right or Wrong? Werner Nutt.

Similar presentations


Presentation on theme: "XML Data Management XPath Exercises: Right or Wrong? Werner Nutt."— Presentation transcript:

1 XML Data Management XPath Exercises: Right or Wrong? Werner Nutt

2 Right or Wrong? 1.How many calories are in Linguine alla Pescatora? /recipes/recipe[title/text()= "Linguine alla Pescatora"] /nutrition/@calories … and what about style?

3 Right or Wrong? 4. Which recipe has the highest number of calories? //recipe[nutrition/@calories > preceding::nutrition/@calories | nutrition/@calories > following::nutrition/@calories] /title … and what about style?

4 Right or Wrong? 4. Which recipe has the highest number of calories? //recipe[not(nutrition/@calories <= preceding::recipe/nutrition/@calories) and not(nutrition/@calories <= following::recipe/nutrition/@calories) and not(nutrition/@calories <= ancestor::recipe/nutrition/@calories)] … and what about style?

5 Right or Wrong? 6. How many compound ingredients (i.e., ingredients with ingredients) are there in Ricotta Pie? count(/recipes/recipe[title/text() = "Ricotta Pie"] /.//ingredient[./ingredient]) … and what about style?

6 Right or Wrong? 8. Which recipes have an ingredient whose preparation needs more steps than are needed for the recipe itself (i.e., top level steps)? //recipe[count(ingredient/preparation/step) > count(preparation/step)] … and what about style?

7 Right or Wrong? 8. Which recipes have an ingredient whose preparation needs more steps than are needed for the recipe itself (i.e., top level steps)? /recipes/recipe [.//ingredient [count(preparation/step) > count(./ancestor::*[name()='recipe'][1] /preparation/step)]] … and what about style?

8 Right or Wrong? 13. Return the ingredients of recipes other than Zuppa Inglese that these recipes have in common with Zuppa Inglese. //recipe[title != "Zuppa Inglese" and.//ingredient/@name = //recipe[title="Zuppa Inglese”]//ingredient [((@name =./preceding::*//ingredient/@name) or (@name =./following::*//ingredient/@name))] ] //ingredient … and what about style?

9 Right or Wrong? 17. Return the names of those ingredients that are mentioned in a preparation step of their recipe. //ingredient[//preparation/step [contains(text(),@name)]]

10 Right or Wrong? 17. Return the names of those ingredients that are mentioned in a preparation step of their recipe. //ingredient[contains(ancestor::recipe//step, @name)] /@name

11 Right or Wrong? 17. Return the names of those ingredients that are mentioned in a preparation step of their recipe. //ingredient[contains(ancestor::recipe/preparation, @name)] /@name Could we write a query that asks for an occurrence of the ingredient name in any preparation step of the recipe?


Download ppt "XML Data Management XPath Exercises: Right or Wrong? Werner Nutt."

Similar presentations


Ads by Google