Esercitazione XPATH. Paolo Papotti.

Similar documents
cucina thai B3623E0F2A9F30F04C52A691C2B7AB70 Cucina Thai 1 / 6

Compiti estivi classi 1 ABC

frandoli frandoli Serie Acciaio_Steel Collection Brillanti

PROSCIUTTO E UOVA VERDI [ GREEN EGGS AND HAM ITALIAN EDITION ] BY DR. SEUSS

Travel Eating Out. Eating Out - At the Entrance. Eating Out - Ordering food

FORMULA RETROBOTTEGA ANTIPASTI PRIMI

Making food more nourishing

TÈ POMERIDIANO Afternoon tea

Supplement to Pledge Concerning Advertising to Children

OVETTI IN SACCHETTO E SFUSI

The Italian partner for your GELATO!

Molto Gusto Easy Italian Cooking Mario Batali

Ask Manu Italiano [Ep.002] PART 1: How to say "AS SOON AS POSSIBLE" in Italian PART 2: How to say "THAN" when comparing things

The Italian partner for your GELATO!

Parthenope Restaurant UNIQUE ITALIAN CUISINE

Lounge. Design M&P Studio 2010

Chilli Stir-fry High-calorie option

Non dire a nessuno il bene che ti voglio neanche al mondo, sarebbe invidioso di una cosa più grande di lui...

La gamma più simpatica che c è!

LA PASTA DI ARMANDO ARMANDO S PASTA

ITALIAN FOOD AND WINE

Il verbo be. affermativa negativa interrogativa risposte brevi FORMA USO. presentarsi descrivere chiedere provenienza professione e dire l età

AB World Foods FINISHED PRODUCT SPECIFICATION. Version control: Version Product Brand and Name: Dark Soy Sauce Blue Dragon

Il Pollo. Il Pollo

happy slow cooking 220DB3E E5E352C1010BE63612 Happy Slow Cooking 1 / 6

DOWNLOAD OR READ : THE ORIGINAL MUFFIN TIN COOKBOOK 200 FAST DELICIOUS MINI PIES PASTA CUPS GOURMET POCKETS VEGGIE CAKES AND MORE PDF EBOOK EPUB MOBI

Dal cuore della tradizione, la nostra innovazione! Our innovation from the very heart of tradition! Fiorenzo Sgambaro INDICE / INDEX

Nutrition and Wound Healing

Blueberry Waffles (from frozen) with Whipped margarine Light Syrup 1% Milk Unsweetened Coffee or tea Water

Bean Tostada - USDA Recipe D120C

Size makes a difference. What do you get for the calories? Sports drinks and soft drinks

Fruit and Vegetables Recipes Grilled Pineapple

THIS WEEK'S MENU: DAY 2 DAY 1 DAY 3 DAY 5 DAY 4 DAY 6 DAY 7 SMALLER FAMILY HEALTHY PLAN Smaller Family Healthy Plan Garden Vegetable Soup

Racconto Bilingue In Italiano E Portoghese Topo Rato Serie Impara Il Portoghese

German Cooking Today By Dr. Oetker Verlag READ ONLINE

Prep time: 5 min Cook time: 25 min Serves: 1-2 serving

Your specialities, our passion.

Puebla Hot Pot Broth with Avocado Crema

Dal cuore della tradizione, la nostra innovazione! Our innovation from the very heart of tradition! Fiorenzo Sgambaro INDICE / INDEX

Herbacel - AQ Plus Citrus. for optimising the quality, calorie content and cost of burger patties

K, S K, S K, S. TUTTI no IE, NN, M, O,

DOLCI TRADIZIONI DI TOSCANA

Curriculamb. ACF Members Test For Continuing Education Credit

Italian passion chocolate

DOWNLOAD OR READ : BEEF NOODLE CASSEROLE PDF EBOOK EPUB MOBI

Making lives easier, healthier, happier

1800-Calorie Mediterranean Menu

TYSON CHILD NUTRITION SUMMARY

Diccionario Italiano-Espanol/Spagnol- Italiano Dizionario (Spanish Edition) By Vertice Everest

El Ideal Iniciatico (Masoneria) (Spanish Edition) By Oswald Wirth

Commercial Offer / Quotation

Crudità. Degustazione di carpacci, ostriche e crostacei (Consigliato per due persone) Tas$ng of raw seafood (Recommended for two persons) 25,00

per la Mamma Mother s Day

Food Service and Meal Management

YEAR 6 May FREE DOWNLOAD on

Diccionario De Sinonimos Juridicos/ Law Synonymous Dictionary (Diccionarios Tematicos) (Spanish Edition) By M. Casado

Low Fat 5-a-Day Appetizers

LUNCH ASSESSMENT FINDINGS. World School Milk Day, September 2010

Calci-YUM! Bulletin Board Lesson PB

FOUNDATIONS OF RESTAURANT MANAGEMENT & CULINARY ARTS MISE EN PLACE REPORT: ESSENTIAL SKILLS STEPS ESSENTIAL SKILLS STEPS SECOND EDITION

1 cup diced pineapple oz low fat vanilla yogurt TOTAL Dinner Calories Carbohydrates Protein Fat

DRY HARD APPLE CIDER. Nutrition Facts GLUTEN FREE. Serving Size 12 Fluid Ounces About 1.3 Servings per Bottle Amount Per Serving

recipes Per serving: Calories: 61 protein: 0.5 g Fat: 0 Makes: 3 cups (750 ml) Preparation time 15 minutes serves 9

Introduction to Data Management CSE 344. Section 6: Relational Calculus and Some XML

Caffeine By Gene A. Spiller

Antipasti. Plain garlic bread Garlic bread with Tomato sauce 2, Garlic bread with Cheese 2, Zuppa del giorno 1, 2 4.

RANCHERO STEAK & CHEESE WHOLE WHEAT TORNADO. Ingredients

Round and bite-sized with many seeds and juice Good in salads

THE PERFECT MEAL RANGE

THIS WEEK'S MENU: DAY 2 DAY 1 DAY 3 DAY 6 DAY 4 DAY 5 DAY 7 SMALLER FAMILY HEALTHY MENU PLAN Smaller Family Menu Plan Honey Pork Tacos

The Golden Ratio And Fibonacci Numbers By R. A. Dunlap READ ONLINE

frandoli frandoli Serie Acciaio_Steel Collection Family

LEVEL ZERO VOICE CATALYST (4 minutes, individual work): How often do you look at food labels? (Always, sometimes, never) Class vote.

Core System Keto Meal Plan

Breakfast Sandwich Maker. Recipes

CATALOGO. Large Distribution WHITE

ERRARA AND HER PROVINCE

Mixtures and Solutions Stations Lesson Plan by Clara Welch Based on FOSS & Kitchen Chemistry by John Bath, Ph. D. and Sally Mayberry, Ed. D.

Wash before eating. Pods are low in fiber Snap pods and eat with the peas inside

Presented by. Presented by. Grilled Shrimp and Peach Satay (Serves 4)

The Ketogenic Diet: The Low Carb Guide To Weight Loss (Includes A Diet Meal Plan) [Kindle Edition] By Anita Thomas

WINE BAR.

INDICE INDEX. Introduzione Introduction... 3

Common sense and nothing else. That s the concept behind the Natural Nordic BIOSoda series of organic soft drinks from Bottlers Group.

COMPONENTS APPENDIABITI. . inspired by ALBA COAT HANGERS COAT HANGERS. . inspired by ALBA

H O L I D A Y H E A L T H NUTRITIOUS TIME SAVING MEALS

SCULPT 6 WEEK FIT BODY SCULPT

The Sandwich Swap By Queen Rania Al Abdullah With Kelly


Chocolate Fruit & Nut Protein Uglies

The American Boulangerie: Authentic French Pastries And Breads For The Home Kitchen By Paul Moore, Pascal Rigo

BONBONS COLLECTION SINCE 1826

A WALK THROUGH THE VINEYARDS INTO THE WORLD OF WINE WITH ROBERTO GULDENER

Book Of Etiquette, Vol. I (in 2 Volumes) By Lillian Eichler READ ONLINE

Healthy Thanksgiving Feast

THOROUGHBRED ROOM NUTRITION INFORMATION

COCKTAILS LIST PRIMAVERA- SPRING 2018

Eating Out and Staying Healthy!

PORCELLANA VALENTINA. Loc. Prataroni s.n. Zona Industriale CIVITA CASTELLANA (VT) Tel Fax

Broccoli Cheese Cornbread Muffins Breads Nutrition Facts

Transcription:

Esercitazione XPATH Paolo Papotti http://papotti.dia.uniroma3.it

Recipes <!ELEMENT recipes (recipe*)> <!ELEMENT recipe (title, ingredient+, preparation, comment?, nutrition)> <!ELEMENT title (#PCDATA)> <!ELEMENT ingredient (ingredient*,preparation?)> <!ATTLIST ingredient name CDATA #REQUIRED amount CDATA #IMPLIED unit CDATA #IMPLIED> <!ELEMENT preparation (step+)> <!ELEMENT step (#PCDATA)> <!ELEMENT nutrition EMPTY> <!ELEMENT comment (#PCDATA)> <!ATTLIST nutrition calories CDATA #REQUIRED fat CDATA #REQUIRED carbohydrates CDATA #REQUIRED protein CDATA #REQUIRED alcohol CDATA #IMPLIED> <recipes> <recipe> <title>beef Parmesan</title> <ingredient name="beef" amount="1.5" unit="pound"/> <ingredient name="onion" amount="1"/> <ingredient name="green rings" amount="1"/> <preparation> <step>boil pasta</step> </preparation> <comment> </comment> <nutrition calories="1167" fat="23" carbohydrates="45" protein="32"/> </recipe>

XPath solutions - recipes "The titles of all recipes that use olive oil. //recipe[ingredient/@name="olive oil"]/title //recipe[.//ingredient/@name="olive oil"]/title //recipe[.//ingredient/@name="olive oil"]/title/text()

XPath queries - recipes 1. "The titles of all recipes, returned as strings." 2. "The titles of all recipes with less than 500 calories." 3. "The titles of all recipes that do not use butter." 4. "The amount of sugar needed for Zuppa Inglese." 5. "The first two steps in preparing Zuppa Inglese." 6. " The titles of all recipes that requires five steps."

XPath - recipes 1. "The titles of all recipes, returned as strings." - fn:doc("recipes.xml")//title/text()

XPath - recipes 1. "The titles of all recipes, returned as strings." - fn:doc("recipes.xml")//title/text() 2. " The titles of all recipes with less than 500 calories." - //recipe[nutrition/@calories < 500]/title - //recipe[//@calories < 500]/title [no!]

XPath - recipes 1. "The titles of all recipes, returned as strings." - fn:doc("recipes.xml")//title/text() 2. " The titles of all recipes with less than 500 calories." - //recipe[nutrition/@calories < 500]/title - //recipe[//@calories < 500]/title [no!] 3. " The titles of all recipes that do not use butter." - //recipe[not(.//ingredient/@name="butter")]/title - //recipe[not(./ingredient/@name="butter")]/title [no!]

XPath - recipes 1. "The titles of all recipes, returned as strings." - fn:doc("recipes.xml")//title/text() 2. " The titles of all recipes with less than 500 calories." - //recipe[nutrition/@calories < 500]/title - //recipe[//@calories < 500]/title [no!] 3. " The titles of all recipes that do not use butter." - //recipe[not(.//ingredient/@name="butter")]/title - //recipe[not(./ingredient/@name="butter")]/title [no!] 1. "The amount of sugar needed for Zuppa Inglese." number(//recipe[title="zuppa Inglese"]//ingredient[@name="sugar"]/@amount)

XPath - recipes 1. "The titles of all recipes, returned as strings." - fn:doc("recipes.xml")//title/text() 2. " The titles of all recipes with less than 500 calories." - //recipe[nutrition/@calories < 500]/title - //recipe[//@calories < 500]/title [no!] 3. " The titles of all recipes that do not use butter." - //recipe[not(.//ingredient/@name="butter")]/title - //recipe[not(./ingredient/@name="butter")]/title [no!] 1. "The amount of sugar needed for Zuppa Inglese." number(//recipe[title="zuppa Inglese"]//ingredient[@name="sugar"]/@amount) 5. The first two steps in preparing Zuppa Inglese." //recipe[title="zuppa Inglese"]/preparation/step[position()=1 or position()=2]

XPath - recipes 1. "The titles of all recipes, returned as strings." - fn:doc("recipes.xml")//title/text() 2. " The titles of all recipes with less than 500 calories." - //recipe[nutrition/@calories < 500]/title - //recipe[//@calories < 500]/title [no!] 3. " The titles of all recipes that do not use butter." - //recipe[not(.//ingredient/@name="butter")]/title - //recipe[not(./ingredient/@name="butter")]/title [no!] 1. "The amount of sugar needed for Zuppa Inglese." number(//recipe[title="zuppa Inglese"]//ingredient[@name="sugar"]/@amount) 5. The first two steps in preparing Zuppa Inglese." //recipe[title="zuppa Inglese"]/preparation/step[position()=1 or position()=2] 6. "The titles of all recipes that requires five steps." //recipe[.//step[5]]/title?? //recipe[preparation/step[5]]/title!!

XPath queries - recipes 7. "The number of recipes in the document." 8."The average number of calories per recipe." 9. "The recipes that have an ingredient in common with Zuppa Inglese." 10. "The titles of recipes have some compound ingredients." 11. "The titles of recipes that have no compound ingredients." 12. "The titles of recipes that have only compound ingredients."

XPath solutions - recipes 7. "The number of recipes in the document." count(//recipe)

XPath solutions - recipes 7. "The number of recipes in the document." count(//recipe) 8. "The average number of calories per recipe." sum(//recipe/nutrition/@calories) div count(//recipe)

XPath solutions - recipes 7. "The number of recipes in the document." count(//recipe) 8. "The average number of calories per recipe." sum(//recipe/nutrition/@calories) div count(//recipe) 9. "The recipes that have an ingredient in common with Zuppa Inglese. //recipe[.//ingredient/@name=//recipe[title="zuppa Inglese"]//ingredient/@name]

XPath solutions - recipes 7. "The number of recipes in the document." count(//recipe) 8. "The average number of calories per recipe." sum(//recipe/nutrition/@calories) div count(//recipe) 9. "The recipes that have an ingredient in common with Zuppa Inglese. //recipe[.//ingredient/@name=//recipe[title="zuppa Inglese"]//ingredient/@name] 10. "The titles of recipes have some compound ingredients." //recipe[ingredient/ingredient]/title

XPath solutions - recipes 7. "The number of recipes in the document." count(//recipe) 8. "The average number of calories per recipe." sum(//recipe/nutrition/@calories) div count(//recipe) 9. "The recipes that have an ingredient in common with Zuppa Inglese. //recipe[.//ingredient/@name=//recipe[title="zuppa Inglese"]//ingredient/@name] 10. "The titles of recipes have some compound ingredients." //recipe[ingredient/ingredient]/title 11. "The titles of recipes that have no compound ingredients //recipe[not(ingredient/ingredient)]/title

XPath solutions - recipes 7. "The number of recipes in the document." count(//recipe) 8. "The average number of calories per recipe." sum(//recipe/nutrition/@calories) div count(//recipe) 9. "The recipes that have an ingredient in common with Zuppa Inglese. //recipe[.//ingredient/@name=//recipe[title="zuppa Inglese"]//ingredient/@name] 10. "The titles of recipes have some compound ingredients." //recipe[ingredient/ingredient]/title 11. "The titles of recipes that have no compound ingredients //recipe[not(ingredient/ingredient)]/title 12. "The titles of recipes that have only compound ingredients" //recipe[not(ingredient[not(ingredient)])]/title

XPath - libreria <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE libreria SYSTEM "libreria.dtd"> <?xml-stylesheet href="libreria_trasf.xsl" type="text/xsl"?> <libreria> <libri> <libro> <titolo>xml Programming</titolo> <prezzo valuta="eur">25</prezzo> <autore>mario Rossi</autore> <autore>paolo Bianchi</autore> </libro> <libro> <titolo>java Programming</titolo> <prezzo valuta="usd">30</prezzo> <autore>paolo Bianchi</autore> </libro> </libri> </libreria>

XPath - libreria <?xml version="1.0" encoding="utf-8"?> <!ELEMENT libreria (libri)> <!ELEMENT libri (libro*)> <!ELEMENT libro (titolo,prezzo,autore+)> <!ELEMENT titolo (#PCDATA)> <!ELEMENT prezzo (#PCDATA)> <!ELEMENT autore (#PCDATA)> <!ATTLIST prezzo valuta CDATA #REQUIRED>

XPath - libreria Dato il documento XML libreria.xml, scrivere le espressioni XPath per le seguenti selezioni: 1. L'insieme di tutti gli elementi libro 2. Il titolo del secondo libro dell archivio 3. I libri di Paolo Bianchi 4. I coautori di Mario Rossi 5. Il numero di libri scritti da Mario Rossi 6. L autore di più di un libro

Soluzioni Soluzioni XPath - libreria 1. //libro 1. /libreria/libri/libro[2]/titolo/text() 1. //libro[.//autore = "Paolo Bianchi"]/titolo 1. //libro[.//autore = "Paolo Bianchi"]/autore[not(. = "Paolo Bianchi")] 1. count(//libro[.//autore = "Paolo Bianchi"]) 1. Si può fare (come?) ma è meglio usare XQuery..

Credits Questo materiale è basato su dispense ed esercizi di Ombretta Gaggi @ Università di Padova Alessio Pace, Valter Crescenzi, Paolo Merialdo @ Università Roma Tre