user2374727
user2374727

Reputation:

ERROR: Element is not valid for content model

HELP: the validation error: Element 'ingred' is not valid for content model: '(frontmatter,ingred,prep,comment)' [xml]

Can someone please tell me what I am missing?

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE lovefood [
<!ELEMENT lovefood (frontmatter,ingred,prep,comment)>
<!ELEMENT frontmatter (publisher,title,date,isbn,blurb)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT isbn (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT blurb (#PCDATA)>

<!ELEMENT ingred ((recipe|subrecipe)*)>
<!ATTLIST recipe title CDATA #IMPLIED>
<!ELEMENT recipe (section,ing*)>
<!ELEMENT section (#PCDATA)>
<!ATTLIST subrecipe title CDATA #IMPLIED>
<!ELEMENT subrecipe (ing*)>
<!ATTLIST ing name CDATA #REQUIRED
   amount CDATA #IMPLIED
    unit CDATA #IMPLIED>
<!ELEMENT ing (#PCDATA)>

<!ELEMENT prep (step+)>
<!ELEMENT step (#PCDATA)>

<!ELEMENT comment (photo_of_dish,pagenumber)>
<!ELEMENT photo_of_dish (#PCDATA)>
<!ELEMENT pagenumber (#PCDATA)>
]>

<lovefood>

<frontmatter>
<publisher>Parragon Books Ltd</publisher>
<title>Love Food</title>
<date>2011</date>
<isbn>978-1-4454-4285-3</isbn>
<blurb>Clear and easy-to-follow ingredients lists and step-by-step methods</blurb>
</frontmatter>

<ingred>
<recipe title="Ingredients">
<section>fish and seafood</section>
<ing name="plain flour, for dusting olive oil, for oiling and drizzling"></ing>
<ing name="quantity tomato sauce" amount="1"></ing>
<ing name="mixed fresh seafood" amount="225" unit="g"></ing>
<ing name="red pepper and yellow pepper deseeded and chopped" amount="0.5"></ing>
<ing name="capers, rinsed" amount="1" unit="tbsp"></ing>
<ing name="Taleggio cheese, grated" amount="55" unit="g"></ing>
<ing name="freshly grated parmesan cheese" amount="3" unit="tbsp"></ing>
<ing name="dried oregano" amount="0.5" unit="tsp"></ing>
<ing name="anchovy fillets in oil, drained and sliced" amount="75" unit="g"></ing>
<ing name="black olivees, stoned" amount="10"></ing>
<ing name="salt and pepper"></ing>
</recipe>
</ingred>

<ingred>
<subrecipe title="Pizza Dough">
<ing name="plain flour, plus extra for dusting" amount="225" unit="g"></ing>
<ing name="salt" amount="1" unit="tsp"></ing>
<ing name="easy blend dried yeast" amount="1" unit="tsp"></ing>
<ing name="olive oil" amount="1" unit="tbsp"></ing>
<ing name="lukewarm water" amount="90" unit="ml"></ing>
</subrecipe>
</ingred>

<prep>
<step>
1. To make the pizza dough, sift the flour and salt into a bowl and stir in the         yeast.Make a wheel in the centre and pour in the oil and water. Incorporate the dry ingredients into the liquid, using floured hands.
</step> 
<step>
2. Turn out the dough onto a lightly floured work surface and knead well for 5 minutes,until smooth and elastic. Return to the clean bowl, cover with lightly oiled clingfilm and set aside to rise in a warm place for about 1 hour, or until doubled in size.
</step>
<step>
3. Turn out the dough again onto a lightly floured work surface and knock down. Knead briefly, then roll out the dough into a circle about 6mm/ 1/4 inch thick. Transfer to a lightly oiled baking sheet and push up the edge with your fingers to form a small rim.
</step>
<step>
4. Spread the tomato sauce over the pizza base, almost to the edge.Arrange the mixed seafood, red and yellow peppers and capers evenly on top.
</step>
<step>
5. Sprinkle the cheeses and oregano evenly over the topping. Add the anchovy fillets and olives, drizzle with olive oil.Season to taste with salt and pepper.
</step> 
<step>
6. Bake in a preheated oven, 220 C/ 425 F/ Gas Mark 7, for 20-25 minutes, until the crust is crisp and the cheese has melted.Serve immediately.
</step>
</prep>

<comment>
<photo_of_dish>input photo here</photo_of_dish>
<pagenumber>130</pagenumber>
</comment>

<ingred>
<recipe title="Scallops with porcini and cream sauce">
<section>fish and seafood</section>
<ing name="dried porcini mushrooms" amount="25"></ing>
<ing name="hot water" amount="500" unit="ml"></ing>
<ing name="olive oil" amount="3" unit="tbsp"></ing>
<ing name="butter" amount="40" unit="g"></ing>
<ing name="sliced scallops" amount="350" unit="g"></ing>
<ing name="garlic cloves, very finely chopped" amount="2"></ing>
<ing name="lemon juice" amount="2" unit="tbsp"></ing>
<ing name="double cream" amount="250" unit="ml"></ing>
<ing name="dried fettuccine or papardelle" amount="350" unit="g"></ing>
<ing name="chopped fresh flat leaf parsley, to serve" amount="2" unit="tbsp"></ing>
<ing name="salt and pepper"></ing>
</recipe>
</ingred>

<prep>
<step>
1. Put the porcini and hot water in a bowl and soak for 20 minutes. Strain the mushrooms, reserving the soaking water, and chop roughly. Line a sieve with kitchen paper and strain the mushroom water into a bowl
</step>
<step>
2. Heat the oil and butter in a large frying pan over a medium heat. Add the scallops and cook for 2 minutes, or unitl just golden. Add the garlic and mushrooms, then stir-fry for another minute
</step>
<step>
3. Stir in the lemon juice, cream and 150ml of the mushroom water. Bring to the boil, then simmer over a medium heat for 2-3 minutes, stirring constantly, until the liquid is reduced by half. Season with salt and pepper. Remove from heat.
</step>
<step>
4. Meanwhile, bring a large saucepan of lightly salted water to the boil. Add the pasta, bring back to the boil and cook for 8-10 minutes, until tender but firm. Drain and transfer to a warm serving dish. Briefly reheat the sauce and pour over the pasta. Sprinkle with the parsley and toss well to mix. Serve immediately.
</step>
</prep>

<comment>
<photo_of_dish>input photo here</photo_of_dish>
<pagenumber>126</pagenumber>
</comment>
</lovefood>

Element 'ingred' is not valid for content model: '(frontmatter,ingred,prep,comment)' [xml]

Upvotes: 1

Views: 10139

Answers (2)

mzjn
mzjn

Reputation: 51082

The DTD says that the content model of lovefood is (frontmatter, ingred, prep, comment) (one of each, in that order). The XML content violates that model since it contains the following immediate children of lovefood: frontmatter, ingred, ingred, prep, comment, ingred, prep, comment.

So that needs to be fixed. Exactly how is not obvious, since you have just pasted an XML document without clarifying what structure you actually want.

One thing that looks a bit odd is to have ingred as a parent of recipe. Having it the other way around seems more natural; a recipe contains a listing if ingredients. And since this seems to be a collection of recipes, then I suggest a recipes element with recipe elements as children, so that the content model of lovefood becomes simply (frontmatter, recipes).

Upvotes: 1

peter.murray.rust
peter.murray.rust

Reputation: 38071

Your DTD specifies that lovefood must contain EXACTLY four children in the EXACT order :

<!ELEMENT lovefood (frontmatter,ingred,prep,comment)>

You have more than one ingred. If this is what you want you can change the DTD to:

<!ELEMENT lovefood (frontmatter,ingred+,prep,comment)>

[I agree that the error messages are not always easy to interpret, but that is because it's difficult to decide exactly what is wrong. So use the message to find out WHERE the problem is first]

Upvotes: 2

Related Questions