This program is available in two forms: as an XSLT stylesheet
as an XQuery
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 (since Saxon 9.6, the query uses XQuery 3.0). 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
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 net.sf.saxon.Transform -it:main -xsl:samples/styles/tour.xsl -o:tour.html start=e5
orjava net.sf.saxon.Query -q:samples/query/tour.xq -o:tour.html start=e5
On the .NET platform, the equivalent commands are:Transform -it:main -xsl:samples/styles/tour.xsl -o:tour.html start=e5
orQuery -q:samples/query/tour.xq -o:tour.html start=e5
When you display the resulting HTML file in your browser it should look something like this:
Knight's tour starting at e5