我是這個xml和dtd文件的新手。我需要你的幫助來創建我的模型,以便上傳一個xml文件。 的文件,我有可以在這兩個鏈接找到的工作:如何基於DTD文件/ XML創建Django模型
DTD文件長相像這樣:
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT WHOLE (ENTITY+)>
<!ATTLIST WHOLE
Date CDATA #REQUIRED
>
<!ELEMENT ENTITY (NAME+, ADDRESS*, BIRTH*, PASSPORT*, CITIZEN*)>
<!ATTLIST ENTITY
Id CDATA #REQUIRED
Type (E | P) #REQUIRED
legal_basis CDATA #IMPLIED
reg_date CDATA #IMPLIED
pdf_link CDATA #IMPLIED
programme CDATA #IMPLIED
remark CDATA #IMPLIED
>
<!ELEMENT NAME (LASTNAME?, FIRSTNAME?, MIDDLENAME?, WHOLENAME?, GENDER?, TITLE?, FUNCTION?, LANGUAGE?)>
<!ATTLIST NAME
Id CDATA #REQUIRED
Entity_id CDATA #REQUIRED
legal_basis CDATA #IMPLIED
reg_date CDATA #IMPLIED
pdf_link CDATA #IMPLIED
programme CDATA #IMPLIED
>
<!ELEMENT LASTNAME (#PCDATA)>
<!ELEMENT FIRSTNAME (#PCDATA)>
<!ELEMENT MIDDLENAME (#PCDATA)>
<!ELEMENT WHOLENAME (#PCDATA)>
<!ELEMENT GENDER (#PCDATA)>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT FUNCTION (#PCDATA)>
<!ELEMENT LANGUAGE (#PCDATA)>
<!ELEMENT ADDRESS (NUMBER?, STREET?, ZIPCODE?, CITY?, COUNTRY?, OTHER?)>
<!ATTLIST ADDRESS
Id CDATA #REQUIRED
Entity_id CDATA #REQUIRED
legal_basis CDATA #IMPLIED
reg_date CDATA #IMPLIED
pdf_link CDATA #IMPLIED
programme CDATA #IMPLIED
>
<!ELEMENT NUMBER (#PCDATA)>
<!ELEMENT STREET (#PCDATA)>
<!ELEMENT ZIPCODE (#PCDATA)>
<!ELEMENT CITY (#PCDATA)>
<!ELEMENT COUNTRY (#PCDATA)>
<!ELEMENT OTHER (#PCDATA)>
<!ELEMENT BIRTH (DATE?, PLACE?, COUNTRY?)>
<!ATTLIST BIRTH
Id CDATA #REQUIRED
Entity_id CDATA #REQUIRED
legal_basis CDATA #IMPLIED
reg_date CDATA #IMPLIED
pdf_link CDATA #IMPLIED
programme CDATA #IMPLIED
>
<!ELEMENT DATE (#PCDATA)>
<!ELEMENT PLACE (#PCDATA)>
<!ELEMENT PASSPORT (NUMBER?, COUNTRY?)>
<!ATTLIST PASSPORT
Id CDATA #REQUIRED
Entity_id CDATA #REQUIRED
legal_basis CDATA #IMPLIED
reg_date CDATA #IMPLIED
pdf_link CDATA #IMPLIED
programme CDATA #IMPLIED
>
<!ELEMENT CITIZEN (COUNTRY?)>
<!ATTLIST CITIZEN
Id CDATA #REQUIRED
Entity_id CDATA #REQUIRED
legal_basis CDATA #IMPLIED
reg_date CDATA #IMPLIED
pdf_link CDATA #IMPLIED
programme CDATA #IMPLIED
>
所以如果有人可以幫我創建我的模型,以便通過使用DTD上傳這個XML文件,我會欠你很多!
謝謝!
所以你想解析所有的數據並創建相應的模型並從中加載數據? –