view xsl/unitcard.xsl @ 403:cf8fc32e020a xsl-output

preliminary xsl output
author Dan.Kulinski@dank-laptop.Global.Local
date Thu, 18 Aug 2011 11:14:14 -0600
parents
children a33be6e995c9
line wrap: on
line source

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" method="html" indent="yes" omit-xml-declaration="yes"/>
  <xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
  <xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
  <xsl:template match="/">
    <html>
      <head>
        <title>
          <xsl:value-of select="/army/name"/> - Created in WarFoundry
        </title>
        <style>
          div#armyInfo { font-size: x-large; width: 100%; margin-bottom: 2em; }
          div.unitcard { border: 1px solid black; width: 50%; margin-bottom: 2em; }
          div.unitcard table { width: 100%; }
          div.unitcard table th { background-color: #999999; }
          table.stats { border-collapse: collapse; }
          table.stats tr { border-top: 1px solid black; border-bottom: 1px solid black; }
          table.stats td { border-right: 1px solid black; }
          h3 { font-size: small; font-variant: small-caps; }
          list.equipmentList { font-size: small; }
          list.abilityList { font-size: small; }
        </style>
      </head>
      <body>
        <div id="armyInfo">
            Name: <xsl:value-of select="/army/name"/> <br />
            Points: <xsl:value-of select="/army/pointsUsed"/> of
            <xsl:value-of select="/army/pointsAvailable"/>
        </div>
        <xsl:for-each select="/army/category">
          <xsl:for-each select="./unit">
          <div class="unitcard">
            <table>
              <th align="left" width="50%">
                <xsl:value-of select="../@type"/>:<xsl:value-of select="./@name"/>
              </th>
              <th width="25%">
                Models: <xsl:value-of select="sum(.//@models)"/>
              </th>
              <th width="25%">
                Points: <xsl:value-of select="./@points"/>
              </th>
            </table>
              <table class="stats">
                <xsl:for-each select="./statLine[1]">
                  <tr>
                    <xsl:for-each select="./stat">
                      <td>
                        <b>
                          <xsl:value-of select="translate(./@name,$lower,$upper)"/>
                        </b>
                      </td>
                    </xsl:for-each>
                  </tr>
                </xsl:for-each>
                <xsl:for-each select="./statLine">
                  <tr>
                    <xsl:for-each select="./stat">
                      <td>
                        <xsl:value-of select="./@value"/>
                      </td>
                    </xsl:for-each>
                  </tr>
                </xsl:for-each>
              </table>
            <h3>Equipment</h3>
            <p>
              <list class="equipmentList">
              <xsl:for-each select="./equipmentItem">
                <li>
                  <xsl:value-of select="./@name"/> (<xsl:value-of select="./@count"/>)
                </li>
              </xsl:for-each>
              </list>
            </p>
          </div>
            </xsl:for-each>
          </xsl:for-each>
        <h3>Special Rules</h3>
        <list class="abilityList">
        <xsl:for-each select='//abilityItem[not(@name = preceding::abilityItem/@name)]'>
          <li>
            <xsl:value-of select='@name'/> - <xsl:value-of select='@description'/>
          </li>
        </xsl:for-each>
        </list>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>