2017-12-19 16 views
0

gehe ich in einer Bewertung arbeite versuchen, XML zu lernen, aber wenn ich es valisdate ich diesesXML Val Fehler Sorce Ausgabe Wie

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". 

Diese meine Datei ist

<?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> 

Ich bin nicht sicher, wie man die DTD richtig macht. SCHÜTZE ich die Elemente in der DTD genau so wie ich es in XML mache? Wie werde ich die Null loswerden?

Jede Hilfe wäre amzing PLS oder Links zum Lesen, die meine Probleme skizzieren würde.

Antwort

2

SCHREIBE ICH die Elemente in der DTD genauso wie in XML.

Nein. Sie müssen nicht verschachteln/einrücken und Sie sollten ein Element definitiv nicht mehr als einmal deklarieren.

Wie werde ich die Null loswerden?

Sie erhalten "Null" für die Elemente, die Sie nicht deklariert haben.

Hier ist eine XML-Instanz, die die interne Teilmenge (DTD) geändert hat, um mit dem XML ohne Änderungen zu arbeiten. Nicht sicher, ob du das brauchst oder nicht, aber es sollte dir zumindest einen besseren Startpunkt geben.

<!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>