Saxonica: XSLT and XQuery Processing: Knight's Tour

Knight's Tour

To try out the knight's tour animation, visit here.

Wait for the chessboard to appear (it may take a while if you are on a slow connection, as Saxon is being downloaded into your browser cache from the server). When it appears, click on any square to start the knight's tour of the board.

To see how it works, view the source of the HTML page ("view source" in your browser), and examine the stylesheet.

Much of the stylesheet is concerned with the logic of planning the tour; but this isn't new to Saxon-CE, so it will not be discussed here any further. For an explanation of this code, see Michael Kay's book XSLT 2.0 and XPath 2.0 Programmer's Reference.

Look for the code that responds to the initial mouse click and fires off the tour, by matching a click on a div element whose id attribute singles it out as representing one of the squares on the board.

Look for the code that waits a short time before continuing the tour, using the ixsl:schedule-action extension instruction.

See how the stop button works: it doesn't actually interrupt execution, but merely sets a flag in the HTML document tree which is examined by the code that moves the knight, abandoning the tour when the user has seen enough.

Next