它告诉我银行的内容格式正确但未经验证:
第 26 行第 8 列错误:内容模型“帐户、客户、存款人)*”不允许元素“帐户”
我知道 DTD 是由我解释的并且可能是错误的,但在 XML 中信息很好。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bank [
<!ELEMENT bank (account,customer,depositor)*>
<!ELEMENT account (#PCDATA)>
<!ATTLIST account account-number ID #REQUIRED>
<!ATTLIST account branch-name (Downtown|Perryridge|Brighton) #REQUIRED>
<!ATTLIST account balance NMTOKEN #REQUIRED>
<!ELEMENT customer (#PCDATA)>
<!ATTLIST customer customer-name ID #REQUIRED>
<!ATTLIST customer customer-street CDATA #REQUIRED>
<!ATTLIST customer customer-city CDATA #REQUIRED>
<!ELEMENT depositor (#PCDATA)>
<!ATTLIST depositor account-number IDREF #REQUIRED>
<!ATTLIST depositor customer-name IDREF #REQUIRED>
] >
<bank>
<account account-number="A-101" branch-name="Downtown" balance="500"></account>
<account account-number="A-102" branch-name="Perryridge" balance="400"></account>
<account account-number="A-201" branch-name="Brighton" balance="900"></account>
<customer customer-name="Johnson" customer-street="Alma" customer-city="Palo Alto"></customer>
<customer customer-name="Hayes" customer-street="Main" customer-city="Harrison"></customer>
<depositor account-number="A-101" customer-name="Johnson"></depositor>
<depositor account-number="A-201" customer-name="Johnson"></depositor>
<depositor account-number="A-102" customer-name="Hayes"></depositor>
</bank>
我已经通过几个在线验证器传递了文档,没有找到你提到的错误,表明 XML 是有效的。
为了进行另一个级别的测试,我将 XML 转换为 JSON,结果是正确的 JSON: