外部dtd验证错误:XML解析错误

时间:2016-11-09 20:46:04

标签: xml dtd xml-dtd

我已经尝试了所有我能想到的向前和向后的东西,我已经一次又一次地计算和记录了我的和/或,但这个外部dtd文件仍然被消息无效:& #34; XML解析错误@line 30(最后一行包含"]>"):期望开始标记,'<'没找到。"谁能帮我吗?太多了!

<?xml version="1.0"?>
<!DOCTYPE items 
[
<!ELEMENT items (item+)>
<!ELEMENT item     (description, country, sellingPrice, cost, quantityOnHand, 
                    backorderedAmount, dateLastReceived, quantitySoldYearToDate, 
                    warehouseSection, warehouseShelve, remarks, supplier, supplier+)>
<!ATTLIST item itemNumber ID #REQUIRED>     
<!ELEMENT description  (#PCDATA)>
<!ELEMENT country    (#PCDATA)>
<!ELEMENT sellingPrice      (#PCDATA)>
<!ATTLIST sellingPrice saleItem (Y|N) #REQUIRED>    
<!ELEMENT cost  (#PCDATA)>
<!ELEMENT quantityOnHand (#PCDATA)>
<!ELEMENT backorderedAmount (#PCDATA)>
<!ATTLIST backorderedAmount dateOrdered NMTOKEN #IMPLIED>   
<!ELEMENT dateLastReceived   (month, day, year)>
<!ELEMENT month  (#PCDATA)>
<!ELEMENT day  (#PCDATA)>
<!ELEMENT year  (#PCDATA)>
<!ELEMENT quantitySoldYearToDate    (#PCDATA)>
<!ELEMENT warehouseSection (#PCDATA)>
<!ELEMENT warehouseShelve     (#PCDATA)>
<!ELEMENT remarks     (#PCDATA)>
<!ELEMENT supplier       (number, shipmentLeadTime, supCost)>
<!ELEMENT number  (#PCDATA)>
<!ELEMENT shipmentLeadTime  (#PCDATA)>
<!ATTLIST shipmentLeadTime unit (days|weeks) #REQUIRED>
<!ELEMENT supCost  (#PCDATA)>
]>

1 个答案:

答案 0 :(得分:0)

由于这是一个外部DTD,您的XML文件中是否还有引用此DTD的DOCTYPE声明?如果是这样,您需要从DTD中删除doctype。

这是一个尝试的例子,它注释掉了:

<!--<!DOCTYPE items [-->
<!ELEMENT items (item+)>
<!ELEMENT item     (description, country, sellingPrice, cost, quantityOnHand, 
                    backorderedAmount, dateLastReceived, quantitySoldYearToDate, 
                    warehouseSection, warehouseShelve, remarks, supplier, supplier+)>
<!ATTLIST item itemNumber ID #REQUIRED>     
<!ELEMENT description  (#PCDATA)>
<!ELEMENT country    (#PCDATA)>
<!ELEMENT sellingPrice      (#PCDATA)>
<!ATTLIST sellingPrice saleItem (Y|N) #REQUIRED>    
<!ELEMENT cost  (#PCDATA)>
<!ELEMENT quantityOnHand (#PCDATA)>
<!ELEMENT backorderedAmount (#PCDATA)>
<!ATTLIST backorderedAmount dateOrdered NMTOKEN #IMPLIED>   
<!ELEMENT dateLastReceived   (month, day, year)>
<!ELEMENT month  (#PCDATA)>
<!ELEMENT day  (#PCDATA)>
<!ELEMENT year  (#PCDATA)>
<!ELEMENT quantitySoldYearToDate    (#PCDATA)>
<!ELEMENT warehouseSection (#PCDATA)>
<!ELEMENT warehouseShelve     (#PCDATA)>
<!ELEMENT remarks     (#PCDATA)>
<!ELEMENT supplier       (number, shipmentLeadTime, supCost)>
<!ELEMENT number  (#PCDATA)>
<!ELEMENT shipmentLeadTime  (#PCDATA)>
<!ATTLIST shipmentLeadTime unit (days|weeks) #REQUIRED>
<!ELEMENT supCost  (#PCDATA)>
<!--]>-->

另请参阅此答案:External referenced DTD in XML

如果这不能解答您的问题,请使用minimal, complete, and verifiable example更新。