I have worked with HTML in the past, but am new to XML. I think my code is mostly correct however I cannot figure out how to fix the remaining errors. I think my brain is stuck on HTML mode. Any help would be great. This form just has to validate.
Here is the .XML code

<!DOCTYPE League SYSTEM "teams.dtd"
[
<!ENTITY Tigers SYSTEM "Tigers.bmp" NDATA Graphics>
<!ENTITY Raiders SYSTEM "Raiders.bmp" NDATA Graphics>
<!ENTITY Storm SYSTEM "Storm.bmp" NDATA Graphics>
]>
<League>
<League LName="Eastern Developmental League">
   <Team>
      <Team_Name>Tigers</Team_Name>
      <City>Toledo</City>
      <Logo Source="Tigers"/>
      <Players>
         <Player Position="Centers" PPG="21.2" RPG="11.1">Lionel Diggs</Player>
         <Player Position="Forward" PPG="18.9" RPG="8.4">Andrew Case</Player>
         <Player Position="Forward" PPG="14.4" RPG="5.0">Casey Lewis</Player>
         <Player Position="Guard" PPG="15.4" RPG="3.1" Assists="9.4">Andrew Case</Player>
         <Player Position="Guard" PPG="7.2" RPG="2.5" Assists="3.9">Ray Kee</Player>
      </Players>
   </Team>
   <Team>
      <Team_Name>Raiders</Team_Name>
      <City>Central City</City>
      <Logo Source="Raiders"/>
      <Players>
         <Player Position="Center" PPG="17.2" RPG="14.2">David Thesus</Player>
         <Player Position="Forward" PPG="28.3" RPG="7.0">Troy Thompson</Player>
         <Player Position="Forward" PPG="10.4" RPG="5.3">Gary Coles</Player>
         <Player Position="Guard" PPG="19.2" RPG="5.2" Assists="4.4">Michael Burns</Player>
         <Player Position="Guard" PPG="5.1" RPG="2.1" Assists="12.9">Patrick Dawson</Player>
      </Players>
   </Team>
   <Team>
      <Team_Name>Lightning</Team_Name>
      <City>Philadelphia</City>
      <Players>
         <Player Position="Center" PPG="12.2" RPG="14.2">Tim White</Player>
         <Player Position="Forward" PPG="21.7" RPG="7.8">Michael Keyes</Player>
         <Player Position="Forward" PPG="8.4" RPG="9.4">Bobby Phillips</Player>
         <Player Position="Guard" PPG="13.1" RPG="1.4" Assists="10.3">David Rice</Player>
         <Player Position="Guard" PPG="10.2" RPG="4.1" Assists="8.4">Elroy Watson</Player>
      </Players>
   </Team>
   <Team>
      <Team_Name>Hoopsters</Team_Name>
      <City>Hill County</City>
      <Players>
         <Player Position="Center" PPG="36.8" RPG="14.8">Tim Brubeck</Player>
         <Player Position="Forward" PPG="13.9" RPG="7.2">Steve True</Player>
         <Player Position="Forward" PPG="5.2" RPG="7.9">David Dannon</Player>
         <Player Position="Guard" PPG="12.4" RPG="5.8" Assists="7.3">Kevin Cleveland</Player>
         <Player Position="Guard" PPG="9.5" RPG="6.2" Assists="12.3">Doug Kaufman</Player>
      </Players>
   </Team>
   <Team>
      <Team_Name>Jaguars</Team_Name>
      <City>Jersey City</City>
      <Players>
         <Player Position="Center" PPG="9.4" RPG="15.1">Scott Plank</Player>
         <Player Position="Forward" PPG="24.1" RPG="8.1">Bill Avidman</Player>
         <Player Position="Forward" PPG="10.2" RPG="8.7">Dan Smith</Player>
         <Player Position="Guard" PPG="24.8" RPG="2.9" Assists="9.7">Brett Dickson</Player>
         <Player Position="Guard" PPG="8.1" RPG="6.7" Assists="8.8">Paul Thompson</Player>
      </Players>
   </Team>
   <Team>
      <Team_Name>Storm</Team_Name>
      <City>Rockaway</City>
      <Logo Source="Storm"/>
      <Players>
         <Player Position="Center" PPG="21.4" RPG="14.8">Tom Jay</Player>
         <Player Position="Forward" PPG="16.8" RPG="8.7">Alan Jackson</Player>
         <Player Position="Forward" PPG="8.4" RPG="7.8">Alan Jones</Player>
         <Player Position="Guard" PPG="19.2" RPG="1.8" Assists="14.3">Kevin Browne</Player>
         <Player Position="Guard" PPG="14.8" RPG="5.1" Assists="7.2">Ian Larson</Player>
         <Player Position="Center"></Player>
      </Players>
   </Team>
</League>

Here is the .DTD Code

<!ELEMENT League (Team+)>
<!ATTLIST League LName CDATA #IMPLIED>
        <!ELEMENT Team (Team_Name, City, Logo, Players+)>
                <!ELEMENT Team_Name (#PCDATA)>
                <!ELEMENT City (#PCDATA)>
                <!ELEMENT Logo EMPTY>
                <!ATTLIST Logo Source CDATA #REQUIRED>
                <!ELEMENT Players (Player, Player, Player, Player, Player)>
                        <!ELEMENT Player (#PCDATA)>
                                <!ATTLIST Player Position CDATA #REQUIRED>
                                <!ATTLIST Player PPG CDATA #IMPLIED>
                                <!ATTLIST Player RPG CDATA #IMPLIED>
                                <!ATTLIST Player Assists CDATA #IMPLIED>
<!NOTATION BMP SYSTEM "image/bmp">

ERRORS

Description: The notation "Graphics" must be declared when referenced in the unparsed entity declaration for "Storm".

Description: The notation "Graphics" must be declared when referenced in the unparsed entity declaration for "Tigers".

Description: The notation "Graphics" must be declared when referenced in the unparsed entity declaration for "Raiders".

Description: Unexpected element "Players". The content of the parent element type must match "(Team_Name,City,Logo,Players+)".

Description: Unexpected element "Players". The content of the parent element type must match "(Team_Name,City,Logo,Players+)".
Description: Unexpected element "Players". The content of the parent element type must match "(Team_Name,City,Logo,Players+)".
Description: Unexpected element "Player". The content of the parent element type must match "(Player,Player,Player,Player,Player)".
Description: Unexpected element "League". The content of the parent element type must match "(Team)+".

Description: XML document structures must start and end within the same entity.

Dani AI

Generated

Three quick root causes explain the validator messages: a mismatched notation name for the unparsed images, DTD content-models that don’t match the XML structure, and a malformed root (mismatched League tags). was right to point at the Team/Logo/Players ordering and optionality; correctly called out the NDATA/NOTATION mismatch. The remaining issues come from one empty Player element and inconsistent Position values.

Quick fixes (in order)

  • Fix the root: keep exactly one <League> element (give that element the LName attribute). The “start and end within the same entity” error comes from the extra/mismatched League tag.
  • Match your unparsed-entity notation: the notation name you use in NDATA must exist. Either declare the same notation name you used for those entities, or change the entity declarations to reference the notation you actually declared. The validator will complain until those two names match.
  • Make Logo optional or ensure every Team includes a Logo. The “Unexpected element 'Players'” is usually because the DTD requires Logo but the XML omitted it, so Players appears where Logo was expected.
  • Allow a variable number of players: do not list five Player occurrences explicitly. Make Players contain one or more Player children instead of expecting exactly five. Remove the empty <Player/> in Storm (elements declared as #PCDATA cannot be empty) or give it text.
  • Normalize Position values (e.g., use Center, not Centers) or declare an enumerated attribute to enforce valid values.

Validation checklist

  • First ensure well-formedness (matching start/end tags). Then validate against the DTD.
  • Run a validator (xmllint, an IDE XML validator or an online tool) to get line numbers and iterate.
  • After each structural change re-run the validator; the error messages will then point to remaining, more specific issues.

These steps implement and expand and ’s suggestions and will clear the listed errors quickly.

Recommended Answers

All 3 Replies

in team strom 6 player define is wrong

dtd discribe 5 player

in team Lightning Hoopsters Jaguars
tag logo is not declared

you in dtd make ? so discribed 0 or 1

<!ELEMENT League (Team+)>
<!ATTLIST League LName CDATA #IMPLIED>
        <!ELEMENT Team (Team_Name, City, Logo?, Players+)>
                <!ELEMENT Team_Name (#PCDATA)>
                <!ELEMENT City (#PCDATA)>
                <!ELEMENT Logo EMPTY>
                <!ATTLIST Logo Source CDATA #REQUIRED>
                <!ELEMENT Players (Player)+>
                        <!ELEMENT Player (#PCDATA)>
                                <!ATTLIST Player Position CDATA #REQUIRED>
                                <!ATTLIST Player PPG CDATA #IMPLIED>
                                <!ATTLIST Player RPG CDATA #IMPLIED>
                                <!ATTLIST Player Assists CDATA #IMPLIED>
                                <!NOTATION BMP SYSTEM "image/bmp">

This will fix what you have shown:
1. First the <!NOTATION ....> you have listed as:
<!NOTATION BMP SYSTEM "image/bmp"> - is okay but to use it was not correct in the XML.
2. Correct the three entries in the XML to end as shown below:
<!ENTITY Tigers SYSTEM "Tigers.bmp" NDATA Graphics>

to

<!ENTITY Tigers SYSTEM "Tigers.bmp" NDATA BMP>

  1. This will validate but does Position have some limited values?
    <!ATTLIST Player Position CDATA #REQUIRED>
    if so, you can do something like this:
    <!ATTLIST Player Position (Center | Guard | Forward) #REQUIRED>

Also this line:
<!ELEMENT Team (Team_Name, City, Logo, Players+)>

Should be:
<!ELEMENT Team (Team_Name, City, Logo?, Players)+>
which makes the Logo optional and the entire Team element to occur "at least once"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.