changeset 403:cf8fc32e020a xsl-output

preliminary xsl output
author Dan.Kulinski@dank-laptop.Global.Local
date Thu, 18 Aug 2011 11:14:14 -0600
parents 3a71f8af5bde
children 5d7584a73d7f
files xsl/default_html.xsl xsl/unitcard.xsl
diffstat 2 files changed, 149 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xsl/default_html.xsl	Thu Aug 18 11:14:14 2011 -0600
@@ -0,0 +1,59 @@
+<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:template match="/">
+  <html>
+    <head>
+      <style>
+        table, th, td { border: 1px solid #000; border-spacing: 0; border-collapse: collapse; margin: 0 }
+        table table { width: 100%; border-width: 0; margin: -2px }
+        table table td { border-width:0 1px }
+      </style>
+      <title>
+        <xsl:value-of select="/army/name"/>
+      </title>
+    </head>
+    <body>
+      <div id="armyInfo">
+        <h1>
+          <xsl:value-of select="/army/name"/> - <xsl:value-of select="/army/pointsUsed"/>pts
+        </h1>
+        <xsl:for-each select="/army/category">
+          <table>
+            <xsl:for-each select="./unit/statLine[1]">
+              <tr>
+                <xsl:for-each select="./stat">
+                  <td>
+                    <xsl:value-of select="./@name"/>
+                  </td>
+                </xsl:for-each>
+                <td>Notes</td>
+                <td>Points</td>
+              </tr>
+            </xsl:for-each>
+            <xsl:for-each select="./unit/statLine">
+              <tr>
+                <xsl:for-each select="./stat">
+                  <td>
+                    <xsl:value-of select="./@value"/>
+                  </td>
+                </xsl:for-each>
+                <td>
+                  <xsl:for-each select="../equipmentItem">
+                    <xsl:value-of select="./@name"/> (<xsl:value-of select="./@count"/>),
+                  </xsl:for-each>
+                  <xsl:for-each select="../abilityItem">
+                    <xsl:value-of select="./@name"/> (<xsl:value-of select="./@description"/>),
+                 </xsl:for-each>
+                </td>
+                <td>
+                  <xsl:value-of select="../@points"/>
+                </td>
+              </tr>
+            </xsl:for-each>
+          </table>
+        </xsl:for-each>
+      </div>
+    </body>
+  </html>
+</xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xsl/unitcard.xsl	Thu Aug 18 11:14:14 2011 -0600
@@ -0,0 +1,90 @@
+<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>
\ No newline at end of file