Warning, /education/parley/xslt/flashcards.xsl is written in an unsupported language. File is not indexed.
0001 <?xml version="1.0" encoding="UTF-8"?> 0002 <!-- XSL Stylesheet to transform kvtml-2 files to xhtml in card layout --> 0003 <xsl:stylesheet 0004 version="1.0" 0005 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 0006 xmlns="http://www.w3.org/1999/xhtml"> 0007 0008 <xsl:output 0009 method="xml" 0010 encoding="UTF-8" 0011 standalone="no" 0012 omit-xml-declaration="no" 0013 doctype-public="-//W3C//DTD XHTML 1.1//EN" 0014 doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" 0015 indent="yes" /> 0016 0017 <!-- globale variables --> 0018 <xsl:variable 0019 name="cards_per_page" 0020 select="number(10)" /> 0021 <xsl:variable 0022 name="pages" 0023 select="ceiling(count(/kvtml/entries/entry) div $cards_per_page)" /> 0024 <xsl:variable 0025 name="cards" 0026 select="count(/kvtml/entries/entry)" /> 0027 0028 <xsl:template match="/"> 0029 <html xmlns="http://www.w3.org/1999/xhtml"> 0030 <head> 0031 <title> 0032 <xsl:value-of select="kvtml/information/title" /> 0033 </title> 0034 <meta 0035 http-equiv="content-type" 0036 content="text/html; charset=UTF-8" /> 0037 <meta 0038 http-equiv="Content-Style-Type" 0039 content="text/css" /> 0040 <meta name="description" content="{kvtml/information/title}" /> 0041 <style> 0042 /* A4 format for the page*/ 0043 @page { 0044 size: 21.0cm 29.7cm; 0045 margin: 2cm; 0046 } 0047 0048 body { 0049 margin: 0; 0050 padding: 0; 0051 color: #000; 0052 background-color: #fff; 0053 font: normal normal bold medium 'Arial', 'Helvetica' sans-serif; 0054 text-align: center; 0055 vertical-align: top; 0056 } 0057 0058 table,td { 0059 table-layout: fixed; 0060 border-collapse: collapse; 0061 border-spacing: 0; 0062 border: thin dashed #000; 0063 empty-cells: hide; 0064 text-align: center; 0065 } 0066 0067 table { 0068 margin: auto; 0069 margin-top: 0.5cm; 0070 } 0071 0072 td { 0073 padding: 0cm; 0074 direction:ltr; 0075 text-align: left; 0076 vertical-align: top; 0077 /* A8 format for the flash cards*/ 0078 width: 7.4cm; 0079 height: 5.2cm; 0080 } 0081 0082 img { 0083 margin: 0cm 0.3cm 0.3cm 0.3cm; 0084 padding: 0; 0085 border: 2px; 0086 float: right; 0087 text-align: right; 0088 vertical-align: top; 0089 } 0090 0091 .lesson { 0092 margin: 0.3cm 0.3cm 0.3cm 0.3cm; 0093 padding: 0; 0094 font-size : 0.7em; 0095 font-weight: normal; 0096 text-align: left; 0097 vertical-align: top; 0098 } 0099 0100 .entry { 0101 margin: 1.5cm 0.3cm 0.3cm 0.3cm; 0102 padding: 0; 0103 text-align: center; 0104 vertical-align: middle; 0105 } 0106 0107 .example { 0108 margin: 0.3cm 0.3cm 0.3cm 0.3cm; 0109 padding: 0.3cm 0 0 0; 0110 border-top: 1px solid #000; 0111 font-weight: normal; 0112 text-align: center; 0113 vertical-align: middle; 0114 } 0115 0116 .pronunciation { 0117 color: #00f; 0118 } 0119 0120 </style> 0121 </head> 0122 <body> 0123 <xsl:call-template name="all"> 0124 <xsl:with-param 0125 name="i" 0126 select="$pages" /> 0127 </xsl:call-template> 0128 </body> 0129 </html> 0130 </xsl:template> 0131 0132 <xsl:template name="all"> 0133 <xsl:param name="i" /> 0134 <xsl:choose> 0135 <xsl:when test="$i > 0"> 0136 <!-- make front --> 0137 <xsl:call-template name="page"> 0138 <xsl:with-param 0139 name="index" 0140 select="$pages - $i + 1" /> 0141 <xsl:with-param 0142 name="side" 0143 select="0" /> 0144 </xsl:call-template> 0145 <!-- make back --> 0146 <xsl:call-template name="page"> 0147 <xsl:with-param 0148 name="index" 0149 select="$pages - $i + 1" /> 0150 <xsl:with-param 0151 name="side" 0152 select="1" /> 0153 </xsl:call-template> 0154 <xsl:call-template name="all"> 0155 <xsl:with-param 0156 name="i" 0157 select="$i - 1" /> 0158 </xsl:call-template> 0159 </xsl:when> 0160 <xsl:otherwise> 0161 <xsl:call-template name="break" /> 0162 </xsl:otherwise> 0163 </xsl:choose> 0164 </xsl:template> 0165 0166 <xsl:template name="break"></xsl:template> 0167 0168 <xsl:template name="page"> 0169 <xsl:param name="index" /> 0170 <xsl:param name="side" /> 0171 <table> 0172 <xsl:choose> 0173 <!-- set attributes for front --> 0174 <xsl:when test="$side = 0"> 0175 <xsl:attribute name="id">Front_<xsl:value-of select="$index" /> 0176 </xsl:attribute> 0177 <xsl:attribute name="style">page-break-after:always; direction:ltr;</xsl:attribute> 0178 </xsl:when> 0179 <!-- set attributes for back (with direction:rtl the order of the cards will be 0180 changed and on the dopple-sided print out you'll have the rigth back on the falsh card --> 0181 <xsl:otherwise> 0182 <xsl:attribute name="id">Back_<xsl:value-of select="$index" /> 0183 </xsl:attribute> 0184 <xsl:attribute name="style">page-break-after:always; direction:rtl;</xsl:attribute> 0185 </xsl:otherwise> 0186 </xsl:choose> 0187 <!-- calculate number of flash cards on normal page / last page --> 0188 <xsl:variable name="current_cards"> 0189 <xsl:choose> 0190 <!-- last page --> 0191 <xsl:when 0192 test="$index = $pages and ($cards mod $cards_per_page) !=0"> 0193 <xsl:value-of select="$cards mod $cards_per_page" /> 0194 </xsl:when> 0195 <!-- normal page --> 0196 <xsl:otherwise> 0197 <xsl:value-of select="$cards_per_page" /> 0198 </xsl:otherwise> 0199 </xsl:choose> 0200 </xsl:variable> 0201 <xsl:call-template name="row"> 0202 <xsl:with-param 0203 name="j" 0204 select="$current_cards" /> 0205 <xsl:with-param 0206 name="index" 0207 select="$index" /> 0208 <xsl:with-param 0209 name="side" 0210 select="$side" /> 0211 </xsl:call-template> 0212 </table> 0213 </xsl:template> 0214 0215 <xsl:template name="row"> 0216 <xsl:param name="j" /> 0217 <xsl:param name="index" /> 0218 <xsl:param name="side" /> 0219 <xsl:choose> 0220 <xsl:when test="$j > 0"> 0221 <xsl:variable 0222 name="pos" 0223 select="$j + ($index - 1) * $cards_per_page" /> 0224 <tr> 0225 <td> 0226 <xsl:call-template name="flashcard"> 0227 <xsl:with-param 0228 name="pos" 0229 select="$j + ($index - 1) * $cards_per_page" /> 0230 <xsl:with-param 0231 name="side" 0232 select="$side" /> 0233 </xsl:call-template> 0234 </td> 0235 <td> 0236 <xsl:if test="$j != 1"> 0237 <xsl:call-template name="flashcard"> 0238 <xsl:with-param 0239 name="pos" 0240 select="$j - 1 + ($index - 1) * $cards_per_page" /> 0241 <xsl:with-param 0242 name="side" 0243 select="$side" /> 0244 </xsl:call-template> 0245 </xsl:if> 0246 </td> 0247 </tr> 0248 <xsl:call-template name="row"> 0249 <xsl:with-param 0250 name="j" 0251 select="$j - 2" /> 0252 <xsl:with-param 0253 name="index" 0254 select="$index" /> 0255 <xsl:with-param 0256 name="side" 0257 select="$side" /> 0258 </xsl:call-template> 0259 </xsl:when> 0260 <xsl:otherwise> 0261 <xsl:call-template name="break" /> 0262 </xsl:otherwise> 0263 </xsl:choose> 0264 </xsl:template> 0265 0266 <xsl:template name="flashcard"> 0267 <xsl:param name="pos" /> 0268 <xsl:param name="side" /> 0269 <img 0270 src="hi48-app-parley.png" 0271 alt="Logo" /> 0272 <p class="lesson"> 0273 <xsl:value-of 0274 select="/kvtml/lessons/container/name[../entry/@id=/kvtml/entries/entry[$pos]/@id]" /> 0275 </p> 0276 <xsl:variable 0277 name="pronunciation" 0278 select="/kvtml/entries/entry[$pos]/translation[@id=$side]/pronunciation" /> 0279 <p class="entry"> 0280 <xsl:value-of 0281 select="/kvtml/entries/entry[$pos]/translation[@id=$side]/text" /> 0282 <xsl:if test="$pronunciation"> 0283 <span class="pronunciation"> 0284 [<xsl:value-of select="$pronunciation" />] 0285 </span> 0286 </xsl:if> 0287 </p> 0288 <xsl:variable 0289 name="example" 0290 select="/kvtml/entries/entry[$pos]/translation[@id=$side]/example" /> 0291 <xsl:if test="$example"> 0292 <p class="example"> 0293 <xsl:value-of select="$example" /> 0294 </p> 0295 </xsl:if> 0296 </xsl:template> 0297 0298 </xsl:stylesheet>