我正在将DTD写入我的XML文件。我在元素“发票”上的元素类型“发票”的声明中遇到了相同的错误“ A')'。我的DTD与我的XML相匹配,名称正确,元素顺序正确。任何帮助,将不胜感激。以下是我的DTD和XML文件。
我尝试重新排序DTD的元素,查看我的XML尝试在那里发现错误,但是似乎没有任何效果。
<!ELEMENT InvoiceList (Invoice*) >
<!ELEMENT Invoice (Client, Company, TaxNumber|USt-IdNr, ServicesList, Date, Amount, BankAccount) >
<!ATTLIST Invoice NumberOfInvoice CDATA #IMPLIED>
<!ELEMENT Client (Name, Address)>
<!ELEMENT Name (#PCDATA) >
<!ELEMENT Address (Street, ZipCode, City) >
<!ELEMENT Street (Name, Number) >
<!ELEMENT Number (#PCDATA) >
<!ELEMENT ZipCode (#PCDATA) >
<!ELEMENT City (#PCDATA) >
<!ELEMENT Company (Name, Address) >
<!ELEMENT TaxNumber (#PCDATA) >
<!ELEMENT USt-IdNr (#PCDATA) >
<!ELEMENT ServiceList (Service) >
<!ELEMENT Service (Position, Name, MwSt, Quantity, SinglePrice, TotalPrice) >
<!ATTLIST Service Date CDATA #IMPLIED>
<!ELEMENT Position (#PCDATA) >
<!ELEMENT MwSt (#PCDATA) >
<!ELEMENT Quantity (#PCDATA) >
<!ELEMENT SinglePrice (#PCDATA) >
<!ELEMENT TotalPrice (#PCDATA) >
<!ELEMENT Date (#PCDATA) >
<!ELEMENT Amount (Total|Brutto, Netto, MwSt) >
<!ELEMENT Total (#PCDATA) >
<!ELEMENT Brutto (#PCDATA) >
<!ELEMENT Netto (#PCDATA) >
<!ELEMENT BankAccount (Name, Bank, BLZ, AccountNumber) >
<!ELEMENT Bank (#PCDATA) >
<!ELEMENT BLZ (#PCDATA) >
<!ELEMENT AccountNumber (#PCDATA) >
<InvoiceList>
<Invoice NumberOfInvoice="657321">
<Client>
<Name>Frau Sybille Sonder-Sutterrau</Name>
<Address>
<Street>
<Name>Am Süttelbach</Name>
<Number>17</Number>
</Street>
<ZipCode>77070</ZipCode>
<City>Siedelsuderstadt</City>
</Address>
</Client>
<Company>
<Name>Kleintier Meier GmbH</Name>
<Address>
<Street>
<Name>Meierring</Name>
<Number>3</Number>
</Street>
<ZipCode>81828</ZipCode>
<City>Machthausen</City>
</Address>
<ContactInformation>
<PhoneNumber>0777/987987</PhoneNumber>
<Fax>0777/987789</Fax>
<EMail>klein.meier@tiere.de</EMail>
</ContactInformation>
</Company>
<TaxNumber>88 123/8282 2</TaxNumber>
<ServicesList>
<Service Date="1.1.2017">
<Position>1</Position>
<Name>Antike Holzwürmer</Name>
<MwSt>19%</MwSt>
<Quantity>100</Quantity>
<SinglePrice>1,50</SinglePrice>
<TotalPrice>150,00</TotalPrice>
</Service>
<Service Date="12.1.2017">
<Position>2</Position>
<Name>Holzwurmfutter</Name>
<MwSt>19%</MwSt>
<Quantity>1</Quantity>
<SinglePrice>34,45</SinglePrice>
<TotalPrice>34,45</TotalPrice>
</Service>
<Service Date="12.1.2017">
<Position>3</Position>
<Name>Steinlaus, Petrophaga lorioti</Name>
<MwSt>19%</MwSt>
<Quantity>1</Quantity>
<SinglePrice>777,77</SinglePrice>
<TotalPrice>777,77</TotalPrice>
</Service>
</ServicesList>
<Date>15.1.2017</Date>
<Amount>
<Brutto>962,22</Brutto>
<Netto>808,59</Netto>
<Mwst>153,63</Mwst>
</Amount>
<BankAccount>
<Name>Kleintier Meier</Name>
<Bank>Sparkasse Karlsruhe</Bank>
<BLZ>66050101</BLZ>
<AccountNumber>987654321</AccountNumber>
</BankAccount>
</Invoice>
我正在使用Eclipse对其进行验证。
答案 0 :(得分:1)
使用|
时,应将该组括在括号中。
您应该同时更新Invoice
和Amount
声明...
<!ELEMENT Invoice (Client, Company, (TaxNumber|USt-IdNr), ServicesList, Date, Amount, BankAccount) >
和
<!ELEMENT Amount ((Total|Brutto), Netto, MwSt) >
这些更改之后,您的DTD将有效,但可能不正确;您的XML仍然无法验证,因为仍然存在一些问题...
ContactInformation
不能作为Company
(和ContactInformation
的子代,而只能是{{1},PhoneNumber
和Fax
的子代)完全不在DTD中声明)EMail
。尽管ServicesList
被声明,所以您可能只是错过了声明名下的ServiceList
。s
,但在DTD中声明为Mwst
(注意大小写)。