Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External DTD to XML 1

Status
Not open for further replies.

debonair86

Technical User
Feb 18, 2010
5
GR
Hi to everybody,
I'm trying for hours to find the error below but i can't.
I have an XML with the following code:
Code:
<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE actors SYSTEM "actors.dtd">

<ACTORS>
 <STAGENAME>George Abbott</STAGENAME>
	<WORKSTART>1928</WORKSTART>
	<FAMILYNAME>Abbott</FAMILYNAME>
<FIRSTNAME>George</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH>1887</DATEOFBIRTH>
<DATEOFDEATH>1995</DATEOFDEATH>
<ROLETYPE>playwright, producer</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES> </NOTES>
 
 <STAGENAME>Dan Ackroyd</STAGENAME>
<WORKSTART>1979</WORKSTART>
<FAMILYNAME>Ackroyd</FAMILYNAME>
<FIRSTNAME>Dan</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH></DATEOFBIRTH>
<DATEOFDEATH></DATEOFDEATH>
<ROLETYPE>comic</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES> </NOTES>
 

 <STAGENAME>Isabelle Adjani</STAGENAME>
<WORKSTART>1971</WORKSTART>
<FAMILYNAME>Adjani</FAMILYNAME>
<FIRSTNAME>Isabelle </FIRSTNAME>
<GENDER>F</GENDER>
<DATEOFBIRTH>1955</DATEOFBIRTH>
<DATEOFDEATH></DATEOFDEATH>
<ROLETYPE>lead</ROLETYPE>
<ORIGIN>French</ORIGIN>
<NOTES> </NOTES>
 

 <STAGENAME>Ben Affleck</STAGENAME>
<WORKSTART>1997</WORKSTART>
<FAMILYNAME>Affleck</FAMILYNAME>
<FIRSTNAME>Ben</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH></DATEOFBIRTH>
<DATEOFDEATH></DATEOFDEATH>
<ROLETYPE>lead</ROLETYPE>
<ORIGIN>American </ORIGIN>
<NOTES></NOTES>
 

 <STAGENAME>Muhammed Ali</STAGENAME>
<WORKSTART>1977</WORKSTART>
<FAMILYNAME>Clay</FAMILYNAME>
<FIRSTNAME>Cassius</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH>1942</DATEOFBIRTH>
<DATEOFDEATH></DATEOFDEATH>
<ROLETYPE>unknown</ROLETYPE>
<ORIGIN>Black-American</ORIGIN>
<NOTES> ALSO: Boxing champion</NOTES>
 

 <STAGENAME>Woody Allen</STAGENAME>
<WORKSTART>1965</WORKSTART>
<FAMILYNAME>Konigsberg</FAMILYNAME>
<FIRSTNAME>Allen Stewart</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH>1935</DATEOFBIRTH>
<DATEOFDEATH></DATEOFDEATH>
<ROLETYPE>confused innocent</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES></NOTES>
 


 <STAGENAME>Pedro Almodovar</STAGENAME>
<WORKSTART> </WORKSTART>
<FAMILYNAME>Almodovar</FAMILYNAME>
<FIRSTNAME>Pedro</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH> </DATEOFBIRTH>
<DATEOFDEATH> </DATEOFDEATH>
<ROLETYPE>wild</ROLETYPE>
<ORIGIN>Spanish</ORIGIN>
<NOTES>MAINLY: Director</NOTES>
 

 <STAGENAME>Maya Angelou</STAGENAME>
<WORKSTART>1993</WORKSTART>
<FAMILYNAME>Angelou</FAMILYNAME>
<FIRSTNAME>Maya</FIRSTNAME>
<GENDER>F</GENDER>
<DATEOFBIRTH>1929</DATEOFBIRTH>
<DATEOFDEATH> </DATEOFDEATH>
<ROLETYPE>poet</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES> </NOTES>
 

 <STAGENAME>Louis Armstrong</STAGENAME>
<WORKSTART>1936</WORKSTART>
<FAMILYNAME>Armstrong</FAMILYNAME>
<FIRSTNAME>Louis Satchmo</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH>1900</DATEOFBIRTH>
<DATEOFDEATH>1971</DATEOFDEATH>
<ROLETYPE>black jazz musician</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES> </NOTES>
 

 <STAGENAME>Dan Aykroyd</STAGENAME>
<WORKSTART>1980</WORKSTART>
<FAMILYNAME>Aykroyd</FAMILYNAME>
<FIRSTNAME>Dan</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH> </DATEOFBIRTH>
<DATEOFDEATH> </DATEOFDEATH>
<ROLETYPE>comic lead</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES> </NOTES>
 

 <STAGENAME>Drew Barrymore</STAGENAME>
<WORKSTART>1982</WORKSTART>
<FAMILYNAME>Barrymore</FAMILYNAME>
<FIRSTNAME>Drew</FIRSTNAME>
<GENDER>F</GENDER>
<DATEOFBIRTH>1976</DATEOFBIRTH>
<DATEOFDEATH> </DATEOFDEATH>
<ROLETYPE>determined child</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES> </NOTES>
 

 <STAGENAME>Alan Bates</STAGENAME>
<WORKSTART>1959</WORKSTART>
<FAMILYNAME>Bates</FAMILYNAME>
<FIRSTNAME>Alan</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH>1934</DATEOFBIRTH>
<DATEOFDEATH> </DATEOFDEATH>
<ROLETYPE>thoughtful tough</ROLETYPE>
<ORIGIN>British</ORIGIN>
<NOTES> </NOTES>
 

 <STAGENAME>Harry Belafonte</STAGENAME>
<WORKSTART>1053</WORKSTART>
<FAMILYNAME>Belafonte</FAMILYNAME>
<FIRSTNAME>Harry</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH>1927</DATEOFBIRTH>
<DATEOFDEATH> </DATEOFDEATH>
<ROLETYPE>ballad singer</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES> </NOTES>
 

 <STAGENAME>JeanPaul Belmondo</STAGENAME>
<WORKSTART>1958</WORKSTART>
<FAMILYNAME>Belmondo</FAMILYNAME>
<FIRSTNAME>Jean</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH>1933</DATEOFBIRTH>
<DATEOFDEATH> </DATEOFDEATH>
<ROLETYPE>interesting but unhandsome lead</ROLETYPE>
<ORIGIN>French</ORIGIN>
<NOTES> </NOTES>
 

 <STAGENAME>Ingrid Bergman</STAGENAME>
<WORKSTART>1934</WORKSTART>
<FAMILYNAME>Bergman</FAMILYNAME>
<FIRSTNAME>Ingrid</FIRSTNAME>
<GENDER>F</GENDER>
<DATEOFBIRTH>1915</DATEOFBIRTH>
<DATEOFDEATH>1982</DATEOFDEATH>
<ROLETYPE>innocent, strong beauty</ROLETYPE>
<ORIGIN>Swedish</ORIGIN>
<NOTES> </NOTES>
 


 <STAGENAME>Irving Berlin</STAGENAME>
<WORKSTART>1943</WORKSTART>
<FAMILYNAME>Baline</FAMILYNAME>
<FIRSTNAME>Israel</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH>1888</DATEOFBIRTH>
<DATEOFDEATH>1989</DATEOFDEATH>
<ROLETYPE>singer</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES>ALSO: composer</NOTES>
 
</ACTORS>

and I made a dtd like this:
Code:
<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE ACTORS [
<!ELEMENT ACTORS (STAGENAME,WORKSTART?,FAMILYNAME,FIRSTNAME,GENDER,DATEOFBIRTH?,DATEOFDEATH?,ROLETYPE,ORIGIN,NOTES)*>
	
	<!ELEMENT STAGENAME (#PCDATA)>
	<!ELEMENT WORKSTART (#PCDATA)>
	<!ELEMENT FAMILYNAME (#PCDATA)>
	<!ELEMENT FIRSTNAME (#PCDATA)>
	<!ELEMENT GENDER (#PCDATA)>
	<!ELEMENT DATEOFBIRTH (#PCDATA)>
	<!ELEMENT DATEOFDEATH (#PCDATA)>
	<!ELEMENT ROLETYPE (#PCDATA)>
	<!ELEMENT ORIGIN (#PCDATA)>
	<!ELEMENT NOTES (#PCDATA)>
	
	<!ATTLIST  NOTES MAINLY CDATA #IMPLIED>
	<!ATTLIST  NOTES ALSO CDATA #IMPLIED>
]>
But something goes wrong and i cant find it, can anybody help me?
Thaks a lot!
 
[1] Your DOCTYPE declaration in the xml document must be followed by token ("actors") in _complete_ accord with the documentElement's name ("ACTORS"). This is not the case!
><!DOCTYPE actors SYSTEM "actors.dtd">
[tt]<!DOCTYPE [red]ACTORS[/red] SYSTEM "actors.dtd">[/tt]

[2] You should not declare the DOCTYPE in the external subset (actors.dtd). That would result in "duplicate DOCTYPE declarations" error.
[tt]
<?xml version="1.0" encoding="utf-8"?>
[red]<!--[/red]
<!DOCTYPE ACTORS [
[red]-->[/red]
<!ELEMENT ACTORS (STAGENAME, WORKSTART?, FAMILYNAME, FIRSTNAME, GENDER, DATEOFBIRTH?, DATEOFDEATH?, ROLETYPE, ORIGIN, NOTES)*>
[blue]<!-- etc etc... -->[/blue]
[red]<!--[/red]
]>
[red]-->[/red][/tt]
 
Thanks a lot for the reply, i had made a mistake yes i change actors to ACTORS, but it still have problems.
To be more detailed, I have to make an xml file named actors.xml and another named actors.dtd, so how can i connect them such as not to take the result "duplicate DOCTYPE declarations" error, i'm wondering?
(excuse my english)
 
tsuji I follow your instructions csrefully and in actors.dtd I corrected like this:

<?xml version="1.0" encoding="utf-8"?>

<!ELEMENT ACTORS (ACTOR)*>
<!ELEMENT ACTOR (STAGENAME,WORKSTART?,FAMILYNAME,FIRSTNAME,GENDER,DATEOFBIRTH?,DATEOFDEATH?,ROLETYPE,ORIGIN,NOTES)>

<!ELEMENT STAGENAME (#PCDATA)>
<!ELEMENT WORKSTART (#PCDATA)>
<!ELEMENT FAMILYNAME (#PCDATA)>
<!ELEMENT FIRSTNAME (#PCDATA)>
<!ELEMENT GENDER (#PCDATA)>
<!ELEMENT DATEOFBIRTH (#PCDATA)>
<!ELEMENT DATEOFDEATH (#PCDATA)>
<!ELEMENT ROLETYPE (#PCDATA)>
<!ELEMENT ORIGIN (#PCDATA)>
<!ELEMENT NOTES (#PCDATA)>

<!ATTLIST NOTES MAINLY CDATA #IMPLIED>
<!ATTLIST NOTES ALSO CDATA #IMPLIED>
(/code)

and in actors.xml i did this:
(code)
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE ACTORS SYSTEM "actors_new.dtd">

<ACTORS>

<ACTOR>
<STAGENAME>George Abbott</STAGENAME>
<WORKSTART>1928</WORKSTART>
<FAMILYNAME>Abbott</FAMILYNAME>
<FIRSTNAME>George</FIRSTNAME>
<GENDER>M</GENDER>
<DATEOFBIRTH>1887</DATEOFBIRTH>
<DATEOFDEATH>1995</DATEOFDEATH>
<ROLETYPE>playwright, producer</ROLETYPE>
<ORIGIN>American</ORIGIN>
<NOTES> </NOTES>
</ACTOR>........


but when I make the validation again there is an error, plz help me, I'm new to this, and so far I have searched I couldn't found an answer.
Thanks again!
 
That part is already correct. If you don't talk about the validation application you're using, no.
 
It's ok, yes I correct this. Can I ask you something final? Secondly I want the WORKSTART, DATEOFBIRTH and DATEOFDEATH to be implied and the ORIGIN to have the default value American. So I change the dtd like this:
Code:
<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE ACTORS [
<!ELEMENT ACTORS (ACTOR)*>
<!ELEMENT ACTOR (STAGENAME,WORKSTART,FAMILYNAME,FIRSTNAME,GENDER,DATEOFBIRTH,DATEOFDEATH,ROLETYPE,ORIGIN,NOTES)>
	
	<!ELEMENT STAGENAME (#PCDATA)>
	<!ELEMENT WORKSTART (#PCDATA)>
	<!ELEMENT FAMILYNAME (#PCDATA)>
	<!ELEMENT FIRSTNAME (#PCDATA)>
	<!ELEMENT GENDER (#PCDATA)>
	<!ELEMENT DATEOFBIRTH (#PCDATA)>
	<!ELEMENT DATEOFDEATH (#PCDATA)>
	<!ELEMENT ROLETYPE (#PCDATA)>
	<!ELEMENT ORIGIN (#PCDATA)>
	<!ELEMENT NOTES (#PCDATA)>
	
	<!ATTLIST  ACTOR WORKSTART  CDATA #IMPLIED>
	<!ATTLIST  ACTOR DATEOFBIRTH  CDATA #IMPLIED>
	<!ATTLIST  ACTOR DATEOFDEATH  CDATA #IMPLIED>
		<!ATTLIST  ACTOR ORIGIN  CDATA #FIXED "American">
]>
In the validation, seems to be no error BUT when I change the Origin to French, for example, the xml parser allow me and no errors appears. This is false isn't it? It must not allow any changes in the Origin, isn't it true?
 
>It must not allow any changes in the Origin, isn't it true?
It must not. Your validation application is not validating, due to whatever reason such as impropre settings.
 
I take it you mean the "attribute" ACTOR, not the element ACTOR.
 
retake (posted too quick):
I take it you mean the "attribute" ORIGIN, not the element ORIGIN.
 
Yes I want an attribute in Origin so as to have the default value American. So, i wrote it wrong?
 
Not only "default" value, but "fixed" value. It is also implied even without explicitly assigning such attribute.
>So, i wrote it wrong?
That's how it is written, in the above sense. In any case, it is still the same conclusion: the validating application is not doing validation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top