1

给定以下 xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Clients SYSTEM "bank.dtd">
<Clients>
    <account>
        <number>323</number>

        <client>
            <address>
                <street>Sliders</street>
                <city>Tokyo</city>
            </address>
            <identity>1212</identity>
        </client>

        <client>           // HERE IS THE PROBLEM
            <address>
                <street>Jason</street>
                <city>Paris</city>
            </address>
            <identity>1313</identity>
        </client>

        <totoalSum>43333</totoalSum>
    </account>
</Clients>

及其DTD文件:

<?xml version="1.0" encoding="utf-8"?>
<!ELEMENT Clients (account+)>
<!ELEMENT account (number,client,totoalSum)>
<!ELEMENT client (address,identity)>
<!ELEMENT address (street,city)>
<!ELEMENT number (#PCDATA)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT identity (#PCDATA)>
<!ELEMENT totoalSum (#PCDATA)>

我无法对其进行验证。XMLspy 说:

Content model of element 'account' disallows element 'client' at this position.

这样,有问题的行在上面用“HERE”标记。

知道是什么原因造成的吗?

问候

4

1 回答 1

2

client一个元素中有 2个account元素。那就是问题所在!

尝试DTD用这个改变:

<!ELEMENT account (number,client+,totoalSum)>
于 2012-04-12T21:10:03.133 回答