XML Val错误来源如何进行



我正在尝试学习XML的评估中

19: 30  Element type "Name" must not be declared more than once.
20: 33  Element type "Company" must not be declared more than once.
21: 38  Element type "Date_Created" must not be declared more than once.
22: 33  Element type "Programmers" must not be declared more than once.
23: 29  Element type "P1" must not be declared more than once.
24: 29  Element type "P2" must not be declared more than once.
26: 37  Element type "Last_Update" must not be declared more than once.
27: 30  Element type "Link" must not be declared more than once.
29: 30  Element type "Name" must not be declared more than once.
30: 33  Element type "Company" must not be declared more than once.
31: 38  Element type "Date_Created" must not be declared more than once.
32: 37  Element type "Programmers" must not be declared more than once.
33: 29  Element type "P1" must not be declared more than once.
34: 37  Element type "Last_Update" must not be declared more than once.
35: 37  Element type "Link" must not be declared more than once.
64: 19  The content of element type "Programmers" must match "(P1+,P2+)".
67: 26  The content of element type "Accove_Address_Book" must match "null".
74: 19  The content of element type "Programmers" is incomplete, it must match "(P1+,P2+)".
79: 12  The content of element type "Link" must match "null".
80: 21  The content of element type "Accove_Notepad" must match "null".

这是我的文件

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Widgets [
<!ENTITY comp 'Accove Pty Ltd'>
<!ELEMENT Widgets (Catagory)>
<!ELEMENT Catagory (Tool,Storage)>
    <!ELEMENT Tool (ACCOVE)>
        <!ELEMENT ACCOVE (Name+,Company+,Date_Created+,Programmers+,Last_Update+,Link+)>
            <!ELEMENT Name (#PCDATA)>
            <!ELEMENT Company (#PCDATA)>
            <!ELEMENT Date_Created (#PCDATA)>
            <!ELEMENT Programmers (P1+,P2+)>
                <!ELEMENT P1 (#PCDATA)>
                <!ELEMENT P2 (#PCDATA)>
            <!ELEMENT Last_Update (#PCDATA)>
            <!ELEMENT Link (#PCDATA)>
    <!ELEMENT Storage (Accove_Address_Book,Accove_Notepad)>
        <!ELEMENT Accove_Address_Book (#PCDATA)>
            <!ELEMENT Name (#PCDATA)>
            <!ELEMENT Company (#PCDATA)>
            <!ELEMENT Date_Created (#PCDATA)>
            <!ELEMENT Programmers (P3*)>
                <!ELEMENT P1 (#PCDATA)>
                <!ELEMENT P2 (#PCDATA)>
                <!ELEMENT P3 (#PCDATA)>
            <!ELEMENT Last_Update (#PCDATA)>
            <!ELEMENT Link (#PCDATA)>
        <!ELEMENT Accove_Notepad (#PCDATA)>
            <!ELEMENT Name (#PCDATA)>
            <!ELEMENT Company (#PCDATA)>
            <!ELEMENT Date_Created (#PCDATA)>
            <!ELEMENT Programmers (#PCDATA)>
                <!ELEMENT P1 (#PCDATA)>
            <!ELEMENT Last_Update (#PCDATA)>
            <!ELEMENT Link (First*,Second*)>
                <!ELEMENT First (#PCDATA)>
                <!ELEMENT Second (#PCDATA)>
]>
<Widgets>
<Catagory>
    <Tool>
        <ACCOVE>
            <Name>ACCOVE</Name>
            <Company>&comp;</Company>
            <Date_Created>01/07/2011</Date_Created>
            <Programmers>
                <P1>Lauren Mullican</P1>
                <P2>Anthony Ellman</P2>
            </Programmers>
            <Last_Update>06/12/2015</Last_Update>
            <Link>image/weath1.jpg</Link>
        </ACCOVE>
    </Tool>
    <Storage>
        <Accove_Address_Book>
            <Name>Accove Address Book</Name>
            <Company>&comp;</Company>
            <Date_Created>23/04/2013</Date_Created>
            <Programmers>
                <P1>Charlie Darlington,</P1>
                <P2>Nadine Pellegrin</P2>
                <P3>Tobias Paniagua</P3>
            </Programmers>
            <Last_Update>25/04/2013</Last_Update>
            <Link>N/A</Link>
        </Accove_Address_Book>
        <Accove_Notepad>
            <Name>Accove Notepad</Name>
            <Company>&comp;</Company>
            <Date_Created>05/05/2016</Date_Created>
            <Programmers>
                <P1>Anthony Ellman</P1>
            </Programmers>
            <Last_Update>05/05/2016</Last_Update>
            <Link>
                <First>image/note1.jog</First>
                <Second>image/note2.jpg</Second>
            </Link>
        </Accove_Notepad>
    </Storage>
</Catagory>
</Widgets> 

我不确定如何正确执行DTD。我是否在DTD中与XML中的元素相同。我如何摆脱空?

任何帮助都将是对请概述我的问题的阅读或阅读链接。

我在dtd中嵌套与xml中的元素一样。

否。您不需要嵌套/缩进,也绝对不应该多一次声明元素。

我如何摆脱空?

您尚未声明的元素获得" null"。

这是一个XML实例,其内部子集(DTD)已修改以与XML一起使用而无需任何更改。不确定这是否是您需要的,但至少应该给您一个更好的起点。

<!DOCTYPE Widgets [
<!ENTITY comp 'Accove Pty Ltd'>
<!ELEMENT Widgets (Catagory)>
<!ELEMENT Catagory (Tool,Storage)>
<!ELEMENT Tool (ACCOVE)>
<!ELEMENT ACCOVE (Name+,Company+,Date_Created+,Programmers+,Last_Update+,Link+)>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Company (#PCDATA)>
<!ELEMENT Date_Created (#PCDATA)>
<!ELEMENT Programmers (P1+,P2*,P3*)>
<!ELEMENT P1 (#PCDATA)>
<!ELEMENT P2 (#PCDATA)>
<!ELEMENT P3 (#PCDATA)>
<!ELEMENT Last_Update (#PCDATA)>
<!ELEMENT Link (#PCDATA|First|Second)*>
<!ELEMENT Storage (Accove_Address_Book,Accove_Notepad)>
<!ELEMENT Accove_Address_Book (Name+,Company+,Date_Created+,Programmers+,Last_Update+,Link+)>
<!ELEMENT Accove_Notepad (Name+,Company+,Date_Created+,Programmers+,Last_Update+,Link+)>
<!ELEMENT First (#PCDATA)>
<!ELEMENT Second (#PCDATA)>
]>
<Widgets>
    <Catagory>
        <Tool>
            <ACCOVE>
                <Name>ACCOVE</Name>
                <Company>&comp;</Company>
                <Date_Created>01/07/2011</Date_Created>
                <Programmers>
                    <P1>Lauren Mullican</P1>
                    <P2>Anthony Ellman</P2>
                </Programmers>
                <Last_Update>06/12/2015</Last_Update>
                <Link>image/weath1.jpg</Link>
            </ACCOVE>
        </Tool>
        <Storage>
            <Accove_Address_Book>
                <Name>Accove Address Book</Name>
                <Company>&comp;</Company>
                <Date_Created>23/04/2013</Date_Created>
                <Programmers>
                    <P1>Charlie Darlington,</P1>
                    <P2>Nadine Pellegrin</P2>
                    <P3>Tobias Paniagua</P3>
                </Programmers>
                <Last_Update>25/04/2013</Last_Update>
                <Link>N/A</Link>
            </Accove_Address_Book>
            <Accove_Notepad>
                <Name>Accove Notepad</Name>
                <Company>&comp;</Company>
                <Date_Created>05/05/2016</Date_Created>
                <Programmers>
                    <P1>Anthony Ellman</P1>
                </Programmers>
                <Last_Update>05/05/2016</Last_Update>
                <Link>
                    <First>image/note1.jog</First>
                    <Second>image/note2.jpg</Second>
                </Link>
            </Accove_Notepad>
        </Storage>
    </Catagory>
</Widgets>

相关内容

  • 没有找到相关文章

最新更新