[xsl] question on line breaks / chess

Subject: [xsl] question on line breaks / chess
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Fri, 17 Jul 2009 05:55:11 +0200

in the past I created quite some chess animations using shell scripting,
netpbm tools and gifsicle, see eg:

Now I tried to do chess diagrams with XSLT.
Since it should work in browsers I am bound to XSLT 1.0.

The position is stored in board.xml, and the transform is board.xsl.
The stylesheet is referenced by <?xml-stylesheet ...?> in board.xml.

The display of board.xml is not nice because of additional vertical
spacing, but running "xsltproc board.xsl board.xml >board.html" and
viewing board.html all is fine:

Now I have three questions:
1) How can I inspect the output of the transformation in the browser?
   "View source" does not help since it shows the XML input.

2) How can I make the output of the browser transformation similar to
   that of xsltproc?

   board.html looks like this, all in a single line (split into many
   lines here for readybility, only):
   <html><table border="1"><tr><td><img src="gif/brw.gif"><img src="gif/
   bnb.gif"><img src="gif/bbw.gif"><img src="gif/bqb.gif"><img src="gif/
   bkw.gif"><img src="gif/bbb.gif"><img src="gif/bnw.gif"><img src="gif/
   brb.gif"><br><img src="gif/bpb.gif">...
   ...<img src="gif/wrw.gif"><br></td></tr></table></html>

3) Is there a better way than having template matching "f" with mode in
   order to handle field background color appropriately?

  <xsl:template match="row">
      <xsl:when test="(position() mod 2)=0">
        <xsl:apply-templates select="f" mode="w"/><br/>?
        <xsl:apply-templates select="f" mode="b"/><br/>?

  <xsl:template match="f" mode="w">
    <xsl:call-template name="img">>
      <xsl:with-param name="pos" select="position()+0"/>

  <xsl:template match="f" mode="b">
    <xsl:call-template name="img">>
      <xsl:with-param name="pos" select="position()+1"/>

Mit besten Gr|_en / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler
WebSphere DataPower SOA Appliances
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschdftsf|hrung: Erich Baier
Sitz der Gesellschaft: Bvblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

Current Thread