【发布时间】:2018-02-14 03:29:06
【问题描述】:
非常感谢您对这个 xml 代码的帮助。 我是这一切的新手......所以提前非常感谢你! 它是这样的: 在我的课堂上,我写了一个 xml 配方,然后包含了 dtd:
`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE recipe
[
<!ENTITY writer "Matt Tebutt">
<!ENTITY copyright "BBC">
<!ELEMENT recipe (title,preptime,cooktime,serves,comment,ingredients,(burgers,(listitem*,(name,quantity)*),salad,(listitem*,(name,quantity)*),toserve,(listitem*,(name,quantity)*)),method,(step)*)>
<!ELEMENT title (#PCDATA)>
<!ATTLIST title xml:lang NMTOKEN #FIXED "en">
<!ELEMENT preptime (#PCDATA)>
<!ELEMENT cooktime (#PCDATA)>
<!ELEMENT serves (#PCDATA)>
<!ELEMENT comment (#PCDATA)>
<!ELEMENT ingredients (#PCDATA)>
<!ELEMENT burgers (#PCDATA)>
<!ELEMENT listitem (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ATTLIST quantity unit (tablespoon|clove|pinch|bunch|gram) #IMPLIED>
<!ELEMENT salad (#PCDATA)>
<!ELEMENT toserve (#PCDATA)>
<!ELEMENT method (#PCDATA)>
<!ELEMENT step (#PCDATA)>
]>
<recipe>
<title xml:lang="en">Chickpea burgers</title>
<preptime><30 min</preptime>
<cooktime>10 to 30 min</cooktime>
<serves>serves 4</serves>
<comment>
These are delicious vegan burgers with a chilli kick. They can be prepared in advance and left in the fridge until you're ready to cook.
</comment>
<ingredients>
<burgers>
<listitem>
<name>olive oil</name>
<quantity unit="tablespoon">2</quantity>
</listitem>
<listitem>
<name>red onions, diced</name>
<quantity>2</quantity>
</listitem>
<listitem>
<name>garlic, finely chopped</name>
<quantity unit="clove">3</quantity>
</listitem>
<listitem>
<name>ground coriander</name>
<quantity unit="tablespoon">1</quantity>
</listitem>
<listitem>
<name>ground cumin</name>
<quantity unit="tablespoon">0.5</quantity>
</listitem>
<listitem>
<name>ground turmeric</name>
<quantity unit="pinch">1</quantity>
</listitem>
<listitem>
<name>hot red chilli, finely chopped</name>
<quantity>1</quantity>
</listitem>
<listitem>
<name>fresh coriander and the stalks, finely chopped</name>
<quantity unit="bunch">1</quantity>
</listitem>
<listitem>
<name>cooked chickpeas, drained</name>
<quantity unit="gram">2x400</quantity>
</listitem>
<listitem>
<name>lemon, juice only</name>
<quantity> 1</quantity>
</listitem>
<listitem>
<name>ground polenta</name>
<quantity unit="gram">250</quantity>
</listitem>
<listitem>
<name>salt</name>
</listitem>
<listitem>
<name>freshly ground pepper</name>
</listitem>
</burgers>
<salad>
<listitem>
<name>red onion, sliced</name>
<quantity>0.5</quantity>
</listitem>
<listitem>
<name>red pepper, sliced</name>
<quantity>0.5</quantity>
</listitem>
<listitem>
<name>salt</name>
<quantity>to taste</quantity>
</listitem>
<listitem>
<name>ground sumac"</name>
<quantity unit="pinch">1</quantity>
</listitem>
<listitem>
<name>tomatoes, sliced</name>
<quantity>2</quantity>
</listitem>
<listitem>
<name>large handful Cos lettuce leaves</name>
<quantity>1</quantity>
</listitem>
</salad>
<toserve>
<listitem>
<name>Sriracha chilli sauce</name>
<quantity>to taste</quantity>
</listitem>
<listitem>
<name>vegan mayonnaise</name>
<quantity>to taste</quantity>
</listitem>
<listitem>
<name>burger buns</name>
<quantity>4</quantity>
</listitem>
</toserve>
</ingredients>
<method>
<step>
1. Heat the olive oil in a pan and fry the onion and garlic for ten minutes until soft. Add the spices and coriander and cook for another minute. Remove from the heat.
</step>
<step>
2. Pulse the chickpeas in a blender with the onion spice mix. Taste, season with salt and pepper, and add a squeeze of lemon juice. Form the mixture into stiff patties and set aside in the fridge until you are ready to cook.
</step>
<step>
3. For the salad, salt the red onion and red pepper on a plate and leave for 20 minutes.
</step>
<step>
4. When ready to cook the burgers, sprinkle the polenta onto a plate and press the burgers onto the polenta. Heat the sunflower oil in a pan and fry the burgers on both sides until cooked through. (Alternatively, you can bake these on an oiled tray for 15-20 minutes at 200C/180C Fan/Gas 6.)
</step>
<step>
5. To finish the salad, wash the onion and pepper under cold, running water and drain. Sprinkle the sumac over the tomatoes. Combine the tomatoes with the Cos lettuce leaves, red onion and red pepper. Mix together the chilli sauce and mayonnaise in a small dish.
</step>
<step>
6. Serve the burgers in the buns with the salad and chilli dip alongside.
</step>
</method>
</recipe>`
但是我无法获得单元的属性声明。当我尝试验证时,我得到了一个完整的错误列表:
元素类型“listitem”的内容必须匹配“null”。
如果你能帮帮我好吗?!
谢谢!!!
【问题讨论】:
标签: xml dtd xml-validation