The Problem


The purpose of the stylesheet is to produce a knight's tour of the chessboard, in which each square is visited exactly once, as shown in the illustration overleaf. A knight can move to any square that is at the opposite corner of a 3 — 2 rectangle (Figure 12-1).

click to expand
Figure 12-1

The only input to the stylesheet is an indication of the starting square: in modern chess notation, the columns are denoted by the letters a-h starting from the left, and the rows by the numbers 1-8, starting at the bottom. We'll supply the starting square as a parameter to the stylesheet. The stylesheet doesn't need to get anything from the source document. In fact, with XSLT 2.0, there doesn't need to be a source document: the entry point to the stylesheet can be specified as a named template.

We'll build up the stylesheet piece by piece: you can find the complete stylesheet, tour.xsl, on the Wrox web site.

The inspiration for this stylesheet came from Oren Ben-Kiki, who published a stylesheet for solving the eight-queens problem. The concept here is very similar, though the details are quite different.




XSLT 2.0 Programmer's Reference
NetBeansв„ў IDE Field Guide: Developing Desktop, Web, Enterprise, and Mobile Applications (2nd Edition)
ISBN: 764569090
EAN: 2147483647
Year: 2003
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net