XML Schema Problem

  • Thread starter Thread starter Wee
  • Start date Start date

Wee

Wee

Associate
Joined
25 Apr 2006
Posts
130
Location
Scotland
I'm creating an XML document covering one of the groups in the Champoins League, and using a Schema to make sure it's valid and what not.

It's almost done, but I've hit a snag. I have a complex element, called goals, that contains another element, called scorer. It looks like this:

Code:
<goals>
   <scrorer number="1" time="62mins" team="Manchester United">Wayne Rooney</scrorer>
</goals>

My problem is that a game may finish 0 - 0, resulting in no goals, meaning that the scorer element won't be needed. Is there anyway in the Schema (or any other way) to take this into consideration?

Cheers.
 
This is my first go at XML, so bare with me as I'm not totally sure what you mean. :)

Does the <goal/> mean it will become an empty element? And if so, where does the scorer element fit into all of this?
 
Ah, got'cha. :)

So all the data for the element <scorer>, now that it is becoming an empty element, will need to be an attribute? Like so:

Code:
<goal>
<scorer number="1" time="62mins" player="Wayne Rooney" team="Manchester United"/>
</goal>
 
Back
Top Bottom