This program is available in two forms: as an XSLT stylesheet
tour.xsl and as
This is a program whose output is a knight's tour of the chessboard (the knight can start on any square, and has to visit each square exactly once). The XSLT version was published as an example stylesheet in my book XSLT 2.0 Programmers Reference (Wrox Press) but has been completely reworked so it now makes extensive use of features in XSLT 2.0, XPath 2.0 and XQuery. It is worth studying the stylesheet and query as an introduction to the use of the new features in these languages. Comparing the two versions, it can be seen that they are very similar: the only differences are in the surface syntax of the two languages.
The stylesheet can be found in the file
samples/styles/tour.xsl, the query in
samples/query/tour.xq. No source document is required.
You can run this example with Saxon on the Java platform using a command of the form:java -jar saxon9.jar -it:main samples\styles\tour.xsl start=e5 >tour.html
orjava -cp saxon9.jar net.sf.saxon.Query samples\query\tour.xq start=e5 >tour.html
On the .NET platform, the equivalent commands are:Transform -it:main samples\styles\tour.xsl start=e5 >tour.html
orQuery samples\query\tour.xq start=e5 >tour.html
When you display the resulting HTML file in your browser it should look like this:
Knight's tour starting at e5