Appello di Complementi di tecnologie Web

Esercizio I

Scrivi uno schema DTD per il seguente documento:

<recipe source="Marjorie Anderson">
	<dish>Southern Corn Bread</dish>
	<ingredients>
		<ingredient>
		<quantity>1 cup</quantity>
		<component>flour</component>
		</ingredient>
		<ingredient>
		<quantity>4 tablespoons</quantity>
		<component>Royal Baking Powder</component>
		</ingredient>
		<ingredient>
		<quantity>½ teaspoon</quantity>
		<component>salt</component>
		</ingredient>
		<ingredient>
		<quantity>1 cup</quantity>
		<component>corn meal</component>
		</ingredient>
		<ingredient>
		<quantity>1½ cups</quantity>
		<component>whole milk</component>
		</ingredient>
		<ingredient>
		<quantity>4 tablespoons</quantity>
		<component>melted butter</component>
		</ingredient>
	</ingredients>
	<directions>
		<step>Sift flour, baking powder, sugar & salt together.</step>
		<step>Add 1 cup corn meal.</step>
		<step>
		Beat egg in cup and add beaten egg and 1½ cups whole milk 
		to make a batter. Stir well.
		</step>
		<step>
		Add melted shortening and beat until light and thoroughly mixed.
		</step>
		<step>
		Pour into greased shallow pan or greased muffin rings.
		</step>
		<step>
		Bake in hot oven at <temperature>425º F</temperature>
		for <duration>25 minutes</duration>.
		</step>
		<step optional="yes">Cut into squares if cooked in shallow pan.</step>
	</directions>
	<story>
		After my mother-in-law <person>Marjorie Anderson</person>
		died, Beth and I found this recipe written on the "extra recipes" page 
		in a local cookbook in her cupboard. This was published by The Episcopal 
		Churchwomen, Church of Ascension, <city>Mt. Sterling</city>, 
		<state>Kentucky</state>.
	</story>
</recipe>

Esercizio II

Considera il documento XML dell'Esercizio I e scrivi le seguenti interrogazioni in XQuery:

  1. Tutte le componenti (component) degli ingredienti della ricetta ordinate in ordine lessicografico
  2. I passi (step) opzionali della ricetta formattati in Italiano (usando l'elemento passo invece di step)
  3. I passi (step) della ricetta che contengono la parola sugar ordinati in ordine di rilevanza (usare una interrogazione full-text)