I'm trying to code a cookbook, I've done the XML for a recipe but am really struggling to get the correct DTD valid.
Any help would be MASSIVELY appreciated for a noob. Eventually the DTD and XML will have two recipes, hence why there is mention of recipetwo in the DTD.
I keep facing errors such as document element does not allow element 'ingredient' here.
Also error element "prep_ingredient" undefined.
Like I said, any help would be appreciated for a beginner. Thanks!!
This is the DTD so far followed by the XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cookbook [
<!ELEMENT cookbook (frontcover+,body+)>
<!ELEMENT frontcover (title,byline,author)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT byline (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT body (recipeone+,recipetwo+)>
<!ENTITY PUBLISHER "Quadrille Publishing">
<!ENTITY COPYRIGHT "Copyright 2010 Quadrille Publishing">
<title> Alice's Cookbook </title>
<byline> "I love this book. I love everything about it: the recipes, the tone and, as importantly, Alice's warmth." </byline>
<author> Alice Hart </author>
<recipe_title> Honey's Raspberry Turnover </recipe_title>
<prep_time> Hands on Time: 15 mins </prep_time>
<cook_time> 20 mins </cook_time>
<recipe_blurb> Honey, my baker-extraordinaire, puff-pastry-making gradnmother, has been a dab hand with a turnover for as long as I can remember, churning out batches of apple, apricot or raspberry from a handsome blue Aga. Make sure you use all-butter puff pastry; it tastes better and has a much more wholesome ingredient
<ingredient> flour, to dust </ingredient>
<ingredient> <quantity> 500g </quantity> of <food_item> all-butter puff pastry </food_item> </ingredient>
<ingredient> <quantity> 500g </quantity> of <food_item> fresh raspberries </food_item>
<ingredient> <quantity> 125g </quantity> of <food_item> vanilla sugar or caster sugar
<ingredient> <quantity> 1 </quantity> of <food_item> free-range egg yolk </food_item>
mixed with <quantity> 1 tbsp </quantity> <food_item> milk </food_item> </ingredient>
<prep_ingredient> Pastry </prep_ingredient>
<step_one> Flour surface. </step_one>
<step_two> Roll out pastry to form a 1/2 thick rectangle. </step_two>
<step_three> Straighten raggedy edges with a sharp knife. </step_three>
<step_four> Cut pastry into eight even squares of 15x15cm. </step_four>
<prep_ingredient> Raspberries </prep_ingredient>
<step_one> Place a pile of respberries in each square, slightly off centre. </step_one>
<step_two> Add a heaped teaspoon of sugar. </step_two>
<step_three> Using a pastrry brucsh, paint a little water around the edge and bring one
corner to meet its diaganol opposite. </step_three>
<step_four> Press the edges together firmly to seal using the tines of a fork.
<step_five> Repeat to make eight pastries. </step_five>
<step_six> Place pastries on a baking tray. </step_six>
<prep_ingredient> oven time </prep_ingredient>
<step_one> Preheat oven to 200 degrees/fan 190 degrees/gas mark 6. </step_one>
<step_two> Brush pastry with egg wash (yolk and milk mixture). </step_two>
<step_three> Sprinkle with a little more sugar. </step_three>
<step_four> Cut a small vent in the top of each to let the steam out. </step_four>
<step_five> Bake for 20 minutes, until exuberantly plump and golden. </step_five>
<step_six> Cool on a wire rack and serve warm. </step_six>
04-27-2013, 12:38 PM
You've declared that the ingredients_list element contains parsed character data but no ingredient elements. I think that what you want is:
<!ELEMENT ingredients_list (ingredient *)>
04-27-2013, 03:04 PM
That's definitely helped, thanks for such a quick response! So simple too!
I've still got errors such as document type does not allow element "quantity" here