Warning, /education/parley/xslt/table.xsl is written in an unsupported language. File is not indexed.
0001 <?xml version="1.0" encoding="UTF-8"?>
0002 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"
0003 xmlns:xhtml="http://www.w3.org/1999/xhtml">
0004 <!-- XSL Stylesheet to transform kvtml-2 files to html
0005 SPDX-FileCopyrightText: Frederik Gladhorn <frederik.gladhorn@kdemail.net>
0006 SPDX-License-Identifier: GPL-2.0-or-later
0007
0008 The easiest way to use the stylesheet is to include it in the .kvtml file:
0009 <?xml-stylesheet type="text/xsl" href="kvtml_html_stylesheet.xsl"?>
0010 -->
0011
0012 <xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
0013 encoding="UTF-8" omit-xml-declaration="yes" version="1.0" />
0014
0015 <xsl:template match="/">
0016 <html xmlns="http://www.w3.org/1999/xhtml">
0017 <head>
0018 <style type="text/css">
0019 td, th {
0020 border: solid 1px black;
0021 border-collapse: collapse;
0022 }
0023 table {
0024 border: solid 1px black;
0025 border-collapse: collapse;
0026 width: 100%;
0027 }
0028 .comment {
0029 font-style: italic;
0030 }
0031 .firstcolumn {
0032 width: 5%;
0033 }
0034 .contentcell {
0035 width: <xsl:value-of select="95 div count(/kvtml/identifiers/identifier)"/>%;
0036 }
0037 #buttons, #buttons td {
0038 width: auto;
0039 border: none;
0040 }
0041 @media print {
0042 .noprint {
0043 display: none;
0044 }
0045 }
0046 </style>
0047
0048 <script type="text/javascript">
0049 <xsl:text disable-output-escaping="yes"><![CDATA[//<![CDATA[
0050 function toggle_visibility(id) {
0051 var e = document.getElementById(id);
0052 if(e.style.visibility == 'visible')
0053 e.style.visibility = 'hidden';
0054 else
0055 e.style.visibility = 'visible';
0056 }
0057
0058 function set_column_visibility(table, column, visibility) {
0059 if (table == null) {
0060 tables = document.getElementsByTagName("table");
0061 for(var i = 0; i < tables.length; i++) {
0062 if (tables[i].id != "buttons") {
0063 set_column_visibility(tables[i].firstChild, column, visibility);
0064 }
0065 }
0066 return;
0067 }
0068
0069 var tr = table.firstChild;
0070 while (tr != null) {
0071 var td = tr.firstChild;
0072 while (td != null) {
0073 if (td.nodeName == "TD" && td.childNodes.length == 1 && td.childNodes[0].nodeName == "DIV") {
0074 if(column == -1 || td.childNodes[0].id.split("-")[1] == column) {
0075 td.childNodes[0].style.visibility = visibility;
0076 }
0077 }
0078 td = td.nextSibling
0079 }
0080 tr = tr.nextSibling;
0081 }
0082 }
0083 ]]>//]]></xsl:text>
0084 </script>
0085 <title><xsl:value-of select="kvtml/information/title"/></title>
0086 </head>
0087
0088 <body><xsl:apply-templates select="kvtml" /></body>
0089 </html>
0090 </xsl:template>
0091
0092 <xsl:template match="kvtml">
0093 <h1><xsl:value-of select="information/title"/></h1>
0094 <table id="buttons" class="noprint">
0095 <xsl:apply-templates select="/kvtml/identifiers" mode="buttons"/>
0096 </table>
0097 <xsl:apply-templates select="lessons"/>
0098 </xsl:template>
0099
0100
0101 <xsl:template match="lessons">
0102 <xsl:apply-templates select="container" mode="toc"/>
0103 <xsl:apply-templates select="container" mode="entries"/>
0104 </xsl:template>
0105
0106 <xsl:template match="container" mode="toc">
0107 <ul class="noprint">
0108 <li>
0109 <a href="#lesson{count(preceding::container) + count(ancestor::container) + 1}"><xsl:value-of select="name"/></a>
0110 <xsl:apply-templates select="container" mode="toc"/>
0111 </li>
0112 </ul>
0113 </xsl:template>
0114
0115 <xsl:template match="container" mode="entries">
0116 <xsl:choose>
0117 <xsl:when test="count(ancestor::container) = 0">
0118 <h2><a name="lesson{count(preceding::container) + count(ancestor::container) + 1}"><xsl:value-of select="name"/></a></h2>
0119 </xsl:when>
0120 <xsl:when test="count(ancestor::container) = 1">
0121 <h3><a name="lesson{count(preceding::container) + count(ancestor::container) + 1}"><xsl:value-of select="name"/></a></h3>
0122 </xsl:when>
0123 <xsl:when test="count(ancestor::container) = 2">
0124 <h4><a name="lesson{count(preceding::container) + count(ancestor::container) + 1}"><xsl:value-of select="name"/></a></h4>
0125 </xsl:when>
0126 <xsl:otherwise>
0127 <h5><a name="lesson{count(preceding::container) + count(ancestor::container) + 1}"><xsl:value-of select="name"/></a></h5>
0128 </xsl:otherwise>
0129 </xsl:choose>
0130 <xsl:if test="count(child::entry) != 0">
0131 <table>
0132 <tr>
0133 <th></th>
0134 <xsl:apply-templates select="/kvtml/identifiers" mode="header"/>
0135 </tr>
0136 <tr class="noprint">
0137 <td></td>
0138 <xsl:apply-templates select="/kvtml/identifiers" mode="buttonrow"/>
0139 </tr>
0140 <xsl:apply-templates select="entry"/>
0141
0142 <xsl:for-each select="entry">
0143 <xsl:variable name="id" select="@id"/>
0144 <xsl:apply-templates select="/kvtml/entries/entry[@id=$id]"/>
0145 </xsl:for-each>
0146 </table>
0147 </xsl:if>
0148 <xsl:apply-templates select="container" mode="entries"/>
0149 </xsl:template>
0150
0151 <xsl:template match="identifiers/identifier" mode="header">
0152 <th class="numbercell"><xsl:value-of select="name"/></th>
0153 </xsl:template>
0154
0155 <xsl:template match="identifiers/identifier" mode="buttons">
0156 <tr>
0157 <td><xsl:value-of select="name"/>:</td>
0158 <td>
0159 <input type="button" value="Hide all" onclick="set_column_visibility(null, {@id}, 'hidden')" /><xsl:text> </xsl:text>
0160 <input type="button" value="Show all" onclick="set_column_visibility(null, {@id}, 'visible')" />
0161 </td>
0162 </tr>
0163 </xsl:template>
0164
0165 <xsl:template match="identifiers/identifier" mode="buttonrow">
0166 <td>
0167 <input type="button" value="Hide all" onclick="set_column_visibility(this.parentNode.parentNode.parentNode, {@id}, 'hidden')" /><xsl:text> </xsl:text>
0168 <input type="button" value="Show all" onclick="set_column_visibility(this.parentNode.parentNode.parentNode, {@id}, 'visible')" />
0169 </td>
0170 </xsl:template>
0171
0172 <xsl:template match="/kvtml/entries/entry">
0173 <tr><td align="right" class="numbercell"><xsl:value-of select="@id+1" />.</td>
0174 <xsl:apply-templates select="translation"/>
0175 </tr>
0176 </xsl:template>
0177
0178 <xsl:template match="translation">
0179 <td class="contentcell" onclick="toggle_visibility('i{../@id}-{@id}')">
0180 <div id="i{../@id}-{@id}" style="visibility: visible;">
0181 <xsl:value-of select="text"/>
0182 <xsl:apply-templates select="comment"/>
0183 </div>
0184 </td>
0185 </xsl:template>
0186
0187 <xsl:template match="comment">
0188 <span class="comment">
0189 <br/><xsl:value-of select="."/>
0190 </span>
0191 </xsl:template>
0192 </xsl:stylesheet>