xml - how to organise this

Started by
0 comments, last by Rob Loach 19 years, 5 months ago
ok, if there is a better xml forum elswehere, tell me . this is what puzzels me for now. I am going to create an xml document with a dtd. and this is what I have to record.

Olympic Atlanta 1996
  Results sprint 100m
     person: Donovan Bailey (Canada)    time: 09.84
     person: Michael March (USA)    time: 10.00
  results sprint 200m
     ....

Next olympic...
What I see here is that I can create one record of persons (name, country ++ ), and one record (game, type, results ). But wether I make an xml doc based on (game, type) and record athletes and their results .... or based on (name, country ++ ) and record game, type, results.

<?xml version="1.0"?>
<!DOCTYPE doc_root [
	<!ELEMENT doc_root (event*)>
	<!ELEMENT event (name, place, year, athletes*)>
	<!ELEMENT name (#PCDATA)>
	<!ELEMENT place (#PCDATA)>
	<!ELEMENT year (#PCDATA)>
	
	<!ELEMENT athletes (firstname, lastname, country, results*)>
	<!ELEMENT firstname (#PCDATA)>
	<!ELEMENT lastname (#PCDATA)>
	<!ELEMENT country (#PCDATA)>
	
	<!ELEMENT results (category*)>
	
	<!ELEMENT category (cat_name, type*)>
	<!ELEMENT cat_name (#PCDATA)>
	
	<!ELEMENT type (typ_name, result)>
	<!ELEMENT typ_name (#PCDATA)>
	<!ELEMENT result (#PCDATA)>
]>
<doc_root>
	<event>
		<name>Olympic games</name>
		<place>Atlanta</place>
		<year>1996</year>
		<athletes>
			<firstname>Michael</firstname>
			<lastname>March</lastname>
			<country>USA</country>
			<results>
				<category>
					<cat_name>Sprint</cat_name>
					<type>
						<typ_name>100m</typ_name>
						<result>10.00</result>
					</type>
					<type>
						<typ_name>200m</typ_name>
						<result>20.48</result>
					</type>
				</category>
			</results>
		</athletes>
		<athletes>
			<firstname>Michael</firstname>
			<lastname>Johnson</lastname>
			<country>USA</country>
			<results>
				<category>
					<cat_name>Sprint</cat_name>
					<type>
						<typ_name>200m</typ_name>
						<result>19.32</result>
					</type>
				</category>
			</results>
		</athletes>
	</event>
	<event>
		<name>Olympic games</name>
		<place>Barcelona</place>
		<year>1992</year>
		<athletes>
			<firstname>Donovan</firstname>
			<lastname>Bailey</lastname>
			<country>Canada</country>
			<results>
				<category>
					<cat_name>Sprint</cat_name>
					<type>
						<typ_name>100m</typ_name>
						<result>09.84</result>
					</type>
				</category>
			</results>
		</athletes>
	</event>
</doc_root>



or...

<?xml version="1.0"?>
<!DOCTYPE doc_root [
	<!ELEMENT doc_root (event*)>
	<!ELEMENT event (name, place, year, results*)>
	<!ELEMENT name (#PCDATA)>
	<!ELEMENT place (#PCDATA)>
	<!ELEMENT year (#PCDATA)>
	<!ELEMENT results (category*)>
	<!ELEMENT category (cat_name, type*)>
	<!ELEMENT cat_name (#PCDATA)>
	<!ELEMENT type (typ_name, athletes*)>
	<!ELEMENT typ_name (#PCDATA)>
	<!ELEMENT athletes (firstname, lastname, result, country)>
	<!ELEMENT firstname (#PCDATA)>
	<!ELEMENT lastname (#PCDATA)>
	<!ELEMENT result (#PCDATA)>
	<!ELEMENT country (#PCDATA)>
]>
<doc_root>
	<event>
		<name>Olympiske leker</name>
		<place>Atlanta</place>
		<year>1996</year>
		<results>
			<category>
				<cat_name>Sprint</cat_name>
				<type>
					<typ_name>100m</typ_name>
					<athletes>
						<firstname>Michael</firstname>
						<lastname>March</lastname>						
						<result>09.84</result>
						<country>USA</country>
					</athletes>
					<athletes>
						<firstname>Donovan</firstname>
						<lastname>Bailey</lastname>						
						<result>10.00</result>
						<country>Canada</country>
					</athletes>
				</type>
				<type>
					<typ_name>200m</typ_name>
					<athletes>
						<firstname>Michael</firstname>
						<lastname>March</lastname>						
						<result>19.32</result>
						<country>USA</country>
					</athletes>
					<athletes>
						<firstname>Michael</firstname>
						<lastname>Bailey</lastname>						
						<result>20.48</result>
						<country>Canada</country>
					</athletes>
				</type>
			</category>
		</results>
	</event>
	<event>
		<name>Olympiske leker</name>
		<place>Barcelona</place>
		<year>1992</year>
		<results>
			<category>
				<cat_name>Sprint</cat_name>
				<type>
					<typ_name>100m</typ_name>
				</type>
				<type>
					<typ_name>200m</typ_name>
				</type>
			</category>
		</results>
	</event>
</doc_root>



if there is a better way to avoid re-typing the same info over and over again, tell me about it. Now I have to choose to retype each athletes, or each game ...
Advertisement
Evolutional in the Web Dev Forums knows a lot about ASP and XML. You might want to ask him.
Rob Loach [Website] [Projects] [Contact]

This topic is closed to new replies.

Advertisement