Google Blogoscoped

Friday, September 7, 2007

Self-Referential Google Docs Chessboard

In above chessboard, which is actually a Google Spreadsheet embedded using the advanced publishing options, the king and rook automatically switch their places around every hour (not necessarily in compliance with chess rules!).

There's really no use to that, it's just a thought experiment. To reproduce this, first create a new Google Docs spreadsheet. Now for every second field use a black background color and white foreground color, and copy some nice Unicode characters, like the chess pieces, into the cells. Publish the document as webpage and copy the URL of that page. Now go back to edit the original document, hit F2 in a cell and use the new importXml formula – which can be used to reference any kind of external HTML or XML – but reference the spreadsheet you are currently working on itself using the just-published URL (line breaks added):

        "//td[@class='g s1']/text()")

Additionally, the left field's XPath – the second parameter in above function – will grab the value from the right field, and vice versa. You guessed it: this will cause the king and rook to continuously change places! (The update rythm is around once per hour due to Google's caching of importXml. During my first test, after around 8 hours the spreadsheet was broken and just displayed "Loading..." – if you can't see it, I saved a screenshot.)

Update: And... after approximately 10 hours, the second try above broke too and displays "loading" now instead of chessboard figures.


Blog  |  Forum     more >> Archive | Feed | Google's blogs | About


This site unofficially covers Google™ and more with some rights reserved. Join our forum!