Computer Chess Club Archives


Search

Terms

Messages

Subject: Updating the PGN Standard using XML

Author: Andrew Wagner

Date: 17:58:44 06/08/04


I sent out an email about this to a number of people, and an interesting
discussion is in the works. But since I saw a recent mention of this on here, I
thought I would post an explanation of my proposal, see if anyone cares to
comment.

        I would like to propose a new standard for chess notation. XML is
a powerful, up-and-coming technology. I believe that if we take advantage
of this technology, and work with input from authors from the beginning,
we can come up with a new standard which will greatly improve PGN.

        First, let me lecture a moment on XML. I'm not going to go into all the
details of its implementation, but just give an overview of the main
philosophies for those who are unfamiliar with it. XML is a text-based,
datacentric standard similar to HTML, but more powerful, because it is
self-descriptive and extensible, and because of the excellent related
technologies. Let me take those one at a time:

Text-based - Like HTML, it is parsed by a browser, but it gets stored in
pure text. It's also quite readable in its text form.

Datacentric - The idea is to abstract out all the formatting. The only
thing that gets stored in an XML file is actual data. Then other files
can be written to indicate how to format that data, and linked with the original
data file. More on this with the related technologies.

Similar to HTML - It has tags like <body>blah blah</body>, but XML is
more restrictive in its requirements of a well-formed document (for one
example, it's case sensitive).

Self-descriptive - The data describes itself, much like in the PGN
standard. Where in PGN you would see [Event "Blah blah"], in XML you
would see <Event>Blah Blah</Event>.

Extensible - Where HTML has a limited set of tags, everyone who writes an
XML document defines their own tags.

Related technologies - This is where XML really gets its power - in the
technologies that process the XML. The relevant technologies that
I propose using are XSD and XSLT. XSD provides a way to validate an XML
document. So within the XSD file (which is also written in XML), I can say "I
want the XML file to be able to use this element and that element, in this
order, and x number of times, etc." Then there are a number of
available XML validators into which anyone can plug in the XSD file and a
particular XML file to see if the XML file matches the requirements. XSLT is
really the heart of this project. Basically, it transforms an XML file into some
other kind of file.

So, let me give you an example of how my idea works. First, I will
develop a kit. This kit will contain a program which converts from PGN to
this new XML standard. So we have this PGN to XML converter program, and then a
series of XSLT scripts. I'll name three XSLT scripts for now: crosstable.xslt,
playback.xslt, fens.xslt, and pgn.xslt. So now I'll take this PGN file, and feed
it into the converter program, which creates a new XML file with the same data.
Here's a rough example of what the original PGN file and the new XML file would
look like if it was just one game:

[Event "Qualifier 1"]
[Site "Internet Chess Club"]
[Date "2004.04.09"]
[Round "1"]
[White "Trueno"]
[Black "thebaron"]
[Result "0-1"]
[ICCResult "White resigns"]
[WhiteElo "1925"]
[BlackElo "2463"]
[Opening "Grünfeld: exchange variation"]
[ECO "D85"]
[NIC "GI.03"]
[Time "14:13:08"]
[TimeControl "900+1"]

1. d4 Nf6 2. c4 g6 3. Nc3 d5 4. cxd5 Nxd5 5. Nb5 c6 6. Qa4 cxb5 7. Qxb5+
Nc6
{White resigns} 0-1

<?xml version='1.0'?>
<Games>
<Game>
<Event>"ICC tourney 517 (15 1)"</Event>
<Site>"Internet Chess Club"</Site>
<Date>"2004.04.23"</Date>
<Round>"1"</Round>
<White>"PostModernist"</White>
<Black>"Trueno"</Black>
<Result>"1-0"</Result>
<ICCResult>"Black resigns"</ICCResult>
<WhiteElo>"2423"</WhiteElo>
<BlackElo>"1862"</BlackElo>
<Opening>"French: Winawer, advance variation"</Opening>
<ECO>"C16"</ECO>
<NIC>"FR.09"</NIC>
<Time>"14:04:48"</Time>
<TimeControl>"900+1"</TimeControl>

<Moves> 1. e4 e6 2. d4 d5 3. Nc3 Bb4 4. e5 Nc6 5. Nf3 Nge7 6. Bd3 Bxc3+
7. bxc3 O-O 8. Bxh7+ Kxh7 9. Ng5+ Kg8 10. Qh5 Re8 11. Ba3 Nb4 12. Bxb4 c5
13. Bxc5 Qd6 {Black resigns} 1-0  </Moves>
</Game>
</Games>

Then for every new game, there would be another <Game>...</Game> set. As
you can see, this is very similar to the PGN. Now, how to use the XSLT
files? The user would just put the XSLT scripts mentioned above in the
same directory as the XML file, then insert this into the second line of
the file:
<?xml-stylesheet type="text/xsl" href="crosstable.xsl"?>

This tells the parser to use the crosstable script. Now, when the user
opens the XML file in his browswer, it shows as a crosstable (or series
of crosstables, if there are multiple tournaments). And if he changes
"crosstable.xsl" to "PGN.xsl", he gets the PGN format. "FEN.xsl" would
output a list of FENs, and "playback.xsl" would provide a javascript
replay board, similar to those output by ChessBase.

So...this is a rough sketch of my ideas. Hopefully it gives you some idea
of the power of it. Any number of scripts can be written, and they can all
be easily modified. All they do is transform the XML to HTML and
javascript. So please, let me know any feedback you care to offer.
Thanks! Andrew Wagner



This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.