SportsML: Adding Actions
Now that we have a little bit more grasps of SportsML. Let us add some more data in our example. Having the final result is a good thing. Now let us add the half time score and also try and tell how many goals were scored in each period. This is how you would do this:
<sports-event>
<sports-metadata event-status="post-event"/>
<team id="manutd">
<team-metadata>
<name first="Manchester" last="United"
full="Manchester United"/>
</team-metadata>
<team-stats score="1" event-outcome="loss">
<sub-score score="1" period-value="1"/>
<sub-score score="0" period-value="2"/>
</team-stats>
</team>
<team id="barca">
<team-metadata>
<name first="Barcelona" />
</team-metadata>
<team-stats score="3" event-outcome="win">
<sub-score score="1" period-value="1"/>
<sub-score score="2" period-value="2"/>
</team-stats>
</team>
</sports-event>
As you can see we have now added two elements sub-score inside the team-stats element. And we are telling in which period the goal came and also how many goals were scored in that period.
So in a sports results document, we could now publish this result as:
Manchester United - Barcelona 1-3 (1-1)
Let us now look at how to add a bit more data to this result. We are missing goal scorers, so let us add those.
Player actions and SportsML plugins
So we have now given our document valuable data about the site and the event, but we have not told anything about the actions that happened in the event. So let's add some information about goals scored in the match. When it happened, who scored and so on. Again I will only add those parts added, as the document now is going to much longer and then harder to read.
First we have to add the players. This is done between the team elements. Here I am adding the Barcelona players:
<player id="barca7"> <player-metadata uniform-number="7" nationality="Spain"> <name first="David" last="Villa" full="David Villa" /> </player-metadata> </player> <player id="barca10"> <player-metadata uniform-number="10" nationality="Argentina"> <name first="Lionel" last="Messi" full="Lionel Messi" /> </player-metadata> </player> <player id="barca17"> <player-metadata uniform-number="17" nationality="Spain"> <name first="Pedro" last="Rodríguez" full="Pedro Rodríguez" /> </player-metadata> </player>
And here I add the Manchester United player (here I have added the whole team structure to show):
<team id="manutd"> <team-metadata> <name first="Manchester" last="United" full="Manchester United"/> </team-metadata> <team-stats score="1" event-outcome="loss"> <sub-score score="1" period-value="1"/> <sub-score score="0" period-value="2"/> </team-stats> <player id="manutd10"> <player-metadata uniform-number="10" nationality="England"> <name first="Wayne" last="Rooney" full="Wayne Rooney" /> </player-metadata> <player-stats score="1" > <sub-score score="1" period-value="1" /> </player-stats> </player> </team>
In order to add actions you need to use the plugin for the sport you are to create datafile from. Since we are creating a soccer results file, we must therefor use the soccer plugin. There is no need to add any references to this plugin, it is available from the start. So it is only to add those elements and attributes that are related to this plugin.
This is how it looks like for the soccer plugin:
<event-actions> <event-actions-soccer> <action-soccer-score player-idref="barca17" minutes-elapsed="27" /> <action-soccer-score player-idref="manutd10" minutes-elapsed="34" /> <action-soccer-score player-idref="barca10" minutes-elapsed="54" /> <action-soccer-score player-idref="barca7" minutes-elapsed="69" /> </event-actions-soccer> </event-actions>
So with this data we now have marked up the scores for the match. We have, as you may notice not written any names, but refered to the ID we have given the player.
With the code above we can now publish the following results text:
Manchester United - Barcelona 3-1 (1-1)
Scores: 0-1 Pedro Rodriguez(27), 1-1 Wayne Rooney (34), 1-2 Lionel Messi (54), 1-3 David Villa (69).
On the next page we shall add more information about the event site.