Download presentation
Presentation is loading. Please wait.
Published byLoraine Johnston Modified over 9 years ago
1
XML Data Management XPath Exercises: Right or Wrong? Werner Nutt
2
Right or Wrong? 2.Return the titles of the recipes that have more than 500 calories. //recipes/recipe/nutrition[@calories>500] /../title … and what about style?
3
Right or Wrong? 3.Return the recipes for which at least 4 eggs are needed. //recipe[sum(descendant::ingredient [contains(@name,"egg")] /@amount) >= 4] /title
4
Right or Wrong? 4. Which recipe has the highest number of calories? //recipe[nutrition/@calories > preceding::nutrition/@calories and nutrition/@calories > following::nutrition/@calories]
5
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)] … what exactly does this query return?
6
Right or Wrong? 6. How many compound ingredients (i.e., ingredients with ingredients) are there in Ricotta Pie? count(//recipe[title="Ricotta Pie"] /ingredient/ingredient/..) … 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)? //recipe[count(ingredient/preparation/step) > count(preparation/step)]
8
Right or Wrong? 10. Return the names of the ingredients of Zuppa Inglese. //recipe[title="Zuppa Inglese"]/ingredient
9
Right or Wrong? 12.Which recipes have an ingredient in common with Zuppa Inglese? //recipe[title!="Zuppa Inglese"] [.//ingredient/@name = //recipe[title="Zuppa Inglese"] /ingredient/@name]
10
Right or Wrong? 14.Return the names of all elementary ingredients that occur in at least two recipes. //recipe///ingredient [count(.//ingredient) = 0 and (@name = preceding::ingredient/@name or @name = following::ingredient/@name)] /@name
11
Right or Wrong? 14.Return the names of all elementary ingredients that occur in at least two recipes. //recipe[title!=preceding::title] [ingredient/@name = //recipe/ingredient/@name] /ingredient/@name
12
Right or Wrong? 15.Return the titles of all recipes for which some form of egg is needed (like egg whites or egg yolk). //ingredient[@name[contains(.,'egg')]] /ancestor::recipe/title … and what about style?
13
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)]]
14
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
15
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?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.