1

帮助:验证错误:元素 'ingred' 对内容模型无效:'(frontmatter,ingred,prep,comment)' [xml]

有人可以告诉我我错过了什么吗?

<?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>

元素 'ingred' 对内容模型无效:'(frontmatter,ingred,prep,comment)' [xml]

4

2 回答 2

2

您的 DTD 指定 lovefood 必须按照 EXACT 顺序包含 EXACTLY 四个孩子:

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

你有不止一个ingred。如果这是您想要的,您可以将 DTD 更改为:

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

[我同意错误消息并不总是很容易解释,但那是因为很难确定到底哪里出了问题。所以先用消息找出问题出在哪里]

于 2013-05-12T13:13:48.680 回答
1

DTD 表示的内容模型lovefood(frontmatter, ingred, prep, comment)(按顺序各一个)。XML 内容违反了该模型,因为它包含以下直接子代lovefoodfrontmatter, ingred, ingred, prep, comment, ingred, prep,comment.

所以这需要修复。确切的方式并不明显,因为您只是粘贴了一个 XML 文档,而没有明确您真正想要的结构。

看起来有点奇怪的一件事是ingred作为recipe. 反过来似乎更自然。配方包含成分列表。而且既然这看起来是菜谱的集合,那么我建议一个recipesrecipe元素为子元素的元素,这样的内容模型lovefood就变得简单了(frontmatter, recipes)

于 2013-05-12T17:17:10.517 回答