2015-04-18 151 views
0

我試着用1-2驗證驗證這個DTD,但是我在爲什麼它是無效的不確定:爲什麼這個DTD無效?

DTD代碼:

任何幫助將不勝感激!

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE cars 
[ 
    <!ELEMENT car (maker, model, year, colour, engine, number_of_doors, accessories)> 

    <!ELEMENT maker (#PCDATA)> 
    <!ELEMENT model (#PCDATA)> 
    <!ELEMENT year (#PCDATA)> 
    <!ELEMENT colour (#PCDATA)> 
    <!ELEMENT engine (number_of_cylinders)> 
    <!ELEMENT number_of_doors (#PCDATA)> 
    <!ELEMENT accessories (#PCDATA)> 

    <!ELEMENT number_of_cylinders (#PCDATA)> 

    <!ATTLIST accessories radio (yes|no) #REQUIRED 
     air_conditioning (yes|no) #REQUIRED 
     power_windows (yes|no) #REQUIRED 
     power_steering (yes|no) #REQUIRED 
     power_brakes (yes|no) #REQUIRED 
    > 
]> 
+1

顯示您輸入XML,告訴我們驗證了什麼樣的錯誤消息。 – jasso

回答

0

,從而與內部DTD子集XML文檔是有效的,做如下修改:

  1. 更改文檔元素從carscar
  2. 構建與給定內部子集關聯的XML。

    <?xml version="1.0" encoding="UTF-8"?> 
    <!DOCTYPE car 
    [ 
    <!ELEMENT car (maker, model, year, colour, engine, number_of_doors, accessories)> 
    
    <!ELEMENT maker (#PCDATA)> 
    <!ELEMENT model (#PCDATA)> 
    <!ELEMENT year (#PCDATA)> 
    <!ELEMENT colour (#PCDATA)> 
    <!ELEMENT engine (number_of_cylinders)> 
    <!ELEMENT number_of_doors (#PCDATA)> 
    <!ELEMENT accessories (#PCDATA)> 
    
    <!ELEMENT number_of_cylinders (#PCDATA)> 
    
    <!ATTLIST accessories radio (yes|no) #REQUIRED 
        air_conditioning (yes|no) #REQUIRED 
        power_windows (yes|no) #REQUIRED 
        power_steering (yes|no) #REQUIRED 
        power_brakes (yes|no) #REQUIRED> 
    ]> 
    <car> 
        <!-- Finish building out the XML per the internal subset. --> 
    </car>