我有以下.dtd
文件
<!ELEMENT TVSCHEDULE (CHANNEL+)>
<!ELEMENT CHANNEL (BANNER,DAY+)>
<!ELEMENT BANNER (#PCDATA)>
<!ELEMENT DAY (DATE,(HOLIDAY|PROGRAMSLOT+)+)>
<!ELEMENT HOLIDAY (#PCDATA)>
<!ELEMENT DATE (#PCDATA)>
<!ELEMENT PROGRAMSLOT (TIME,TITLE,DESCRIPTION?)>
<!ELEMENT TIME (#PCDATA)>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT DESCRIPTION (#PCDATA)>
<!ATTLIST TVSCHEDULE NAME CDATA #REQUIRED>
<!ATTLIST CHANNEL CHAN CDATA #REQUIRED>
<!ATTLIST PROGRAMSLOT VTR CDATA #IMPLIED>
<!ATTLIST TITLE RATING CDATA #IMPLIED>
<!ATTLIST TITLE LANGUAGE CDATA #IMPLIED>
我不太明白这一行:
<!ELEMENT DAY (DATE,(HOLIDAY|PROGRAMSLOT+)+)>
对于元素
DAY
,在以下语句中,它具有DATE
和Enumeration
+(HOLIDAY
或PROGRAMSLOT+
),哪个正确?答:
DAY
元素仅包含DATE
并且仅包含多个HOLIDAY
B.
DAY
元素仅包含DATE
并且仅包含多个PROGRAMSLOT
C.
DAY
元素包含DATE
以及多个HOLIDAY
和PROGRAMSLOT
我不明白为什么不能将其简化为
<!ELEMENT DAY (DATE,(HOLIDAY|PROGRAMSLOT)+)>
谢谢
最佳答案
我认为是C:
您必须在DAY之后加上一个序列,其中序列中的每个项目的类型均为HOLIDAY或PROGRAMSLOT序列
没有看到PROGRAMSLOT +的意义。用
<!ELEMENT DAY (DATE,(HOLIDAY|PROGRAMSLOT)+)>
您可以实现相同的灵活性。
我认为以下所有示例都是正确的:
DATE, HOLIDAY, HOLIDAY,HOLIDAY
DATE, PROGRAMSLOT, PROGRAMSLOT, PROGRAMSLOT
DATE, PROGRAMSLOT, HOLIDAY, HOLIDAY, PROGRAMSLOT
DATE, HOLIDAY, PROGRAMSLOT, HOLIDAY, PROGRAMSLOT
以下示例无效:
DATE, DATE // DATE can only occur once
DATE // the group of HOLIDAY OR PROGRAMLIST must occur at least once
HOLIDAY, DATE // DATE must be the first element