2012-12-12 51 views
0

我正在爲此處給出的XML編寫DTD。 http://s3.amazonaws.com/spark-public/db/docs/courses-ID.xmlDTD XML不確定性錯誤

我想不出如何編寫Department元素。 這是我的DTD代碼。

<!ELEMENT Course_Catalog (Department+)> 
<!ELEMENT Department ---**don't know what to write here**---> 
<!ATTLIST Department Code CDATA #REQUIRED Chair IDREF #REQUIRED> 
<!ELEMENT Title (#PCDATA)> 
<!ELEMENT Course (Title,Description*)> 
<!ELEMENT Professor (First_Name,Middle_Initial?,Last_Name)> 
<!ELEMENT Lecturer (First_Name,Middle_Initial?,Last_Name)> 
<!ATTLIST Course Number ID #REQUIRED Prerequisites IDREFS #IMPLIED Instructors IDREFS #REQUIRED Enrollment CDATA #IMPLIED> 
<!ATTLIST Professor InstrID ID #REQUIRED> 
<!ATTLIST Lecturer InstrID ID #REQUIRED> 
<!ELEMENT First_Name (#PCDATA)> 
<!ELEMENT Middle_Initial (#PCDATA)> 
<!ELEMENT Last_Name (#PCDATA)> 
<!ELEMENT Description (#PCDATA | Courseref)*> 
<!ELEMENT Courseref EMPTY> 
<!ATTLIST Courseref Number IDREF #REQUIRED> 

請幫幫我。

回答

1

[首先,注意 - 如果您提供了更多的證據表明您自己做了一些工作,您會得到更好的結果提出問題:它使您看起來更像是一個可以使用幫助而不是更少的人就像一個不想自己做任何工作的人一樣,它可以幫助回答者更好地理解他們做什麼,不需要解釋什麼。另外,更全面地說明你已經嘗試了什麼,以及爲什麼它不起作用幾乎總是包含你得到的錯誤信息的帳戶,這對有人想幫助你是有幫助的。如果你想獲得對堆棧溢出的幫助下,它的讀取Eric Raymond on how to ask good questions一個好主意,做什麼,他說:]

您提供的每種樣品文檔中的部門元素恰好與一個標題元素開始,繼續具有可變數量的課程元素,並以教授和講師元素的混合物結束。這部分你不知道如何表達? (究竟它與確定性有什麼關係?)

以下是一些元素聲明,它們將接受示例中的Department元素。

<!ELEMENT Department ANY > 
<!ELEMENT Department (Title | Course | Professor | Lecturer)* > 
<!ELEMENT Department (Title | Course | Professor | Lecturer)+ > 
<!ELEMENT Department (Title, Course*, (Professor | Lecturer)* > 
<!ELEMENT Department (Title, Course+, (Professor | Lecturer)+ > 
<!ELEMENT Department (Title, Course+, (Professor?, Lecturer?)* > 
<!ELEMENT Department (Title, Course+, (Professor?, Lecturer?)+ > 
<!ELEMENT Department (Title, Course*, 
        (Professor | Lecturer | Instructor | TA)* > 
<!ELEMENT Department (Title, Course+, Professor, 
        (Professor | Lecturer)+ > 

這有幫助嗎?

+0

感謝help.Sorry,我會好好照顧未來。 – skjindal93

0

你有什麼試過,沒有奏效?

您可能不知道內容模型可能具有多個括號級別,以便進行分組。類似於

(Title, Course+, (Professor | Lecturer)+) 

應該適用於此XML實例,但其他Course_catalog XML實例可能會顯示其他要求。

0

試試這個

<!ELEMENT Course_Catalog (Department*)> 
<!ELEMENT Department (Title, Course*, (Professor | Lecturer)+)> 
<!ATTLIST Department Code CDATA #REQUIRED 
           Chair IDREF #REQUIRED> 
<!ELEMENT Title (#PCDATA)> 
<!ELEMENT Professor (First_Name, Middle_Initial?, Last_Name)> 
<!ATTLIST Professor InstrID ID #REQUIRED> 
<!ELEMENT First_Name (#PCDATA)> 
<!ELEMENT Last_Name (#PCDATA)> 
<!ELEMENT Course (Title, Description?)> 
<!ELEMENT Description (#PCDATA | Courseref)*> 
<!ELEMENT Courseref EMPTY> 
<!ATTLIST Courseref Number IDREF #REQUIRED> 
<!ATTLIST Course Number ID #REQUIRED 
          Prerequisites CDATA #IMPLIED 
          Instructors IDREFS #REQUIRED 
          Enrollment CDATA #IMPLIED> 
<!ELEMENT Instructors (Professor | Lecturer)+> 
<!ELEMENT Lecturer (First_Name, Middle_Initial?, Last_Name)> 
<!ATTLIST Lecturer InstrID ID #REQUIRED> 
<!ELEMENT Middle_Initial (#PCDATA)> 

感謝, 比馬爾