File: kvtml_html_stylesheet.xsl

package info (click to toggle)
libkeduvocdocument 4%3A20.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,284 kB
  • sloc: cpp: 8,230; makefile: 3; sh: 3
file content (103 lines) | stat: -rw-r--r-- 2,938 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- XSL Stylesheet to transform kvtml-2 files to html
 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

Copyright 2007: Frederik Gladhorn <frederik.gladhorn@kdemail.net>

The easiest way to use the stylesheet is to include it in the .kvtml file:
<?xml-stylesheet type="text/xsl" href="kvtml_html_stylesheet.xsl.xsl"?>

 -->

<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 3.2 Final//EN"/>

	<xsl:template match="/">
	<html>
	<style type="text/css">
		td, table {
			border: solid 1px black;
			border-collapse: collapse;
			width: <xsl:value-of select="100 div count(/kvtml/identifiers/identifier)"/>%;
		}
		tr[languageheader] {
			color: black;
			font-size: 1.5em;
			background-color: lightblue;
		}
		.comment {
			color: blue;
		}
	</style>
	
	<head>
		<title><xsl:value-of select="kvtml/information/title"/></title>
	</head>
	
	<body><xsl:apply-templates select="kvtml" /></body>
	</html>
	</xsl:template>

	<xsl:template match="kvtml">
		<h2><xsl:value-of select="information/title"/></h2>
		<xsl:apply-templates select="lessons"/>
	</xsl:template>


	<xsl:template match="lessons">
		<xsl:for-each select="lesson">
			<a href="#{name}"><xsl:value-of select="name"/></a>
			<br/>
		</xsl:for-each>

		<xsl:apply-templates select="lesson"/>
	</xsl:template>
 
	<xsl:template match="lesson">
		<h3>Lesson: <a name="{name}"><xsl:value-of select="name"/></a></h3>
		<table border="1">
			<tr languageheader="true">
				<xsl:apply-templates select="/kvtml/identifiers"/>
			</tr>
			<xsl:apply-templates select="entries/entry"/>

			<xsl:for-each select="entryid">
				<xsl:variable name="id" select="."/>
				<xsl:apply-templates select="/kvtml/entries/entry[@id=$id]"/>
			</xsl:for-each>	
		</table>
	</xsl:template>
	
	<xsl:template match="identifiers/identifier">
		<td><xsl:value-of select="name"/></td>
	</xsl:template>
	
	<xsl:template match="entry">
		<tr><xsl:apply-templates select="translation"/></tr>
	</xsl:template>
	
	<xsl:template match="translation">
		<td><xsl:value-of select="text"/>
			<xsl:apply-templates select="comment"/>
		</td>
	</xsl:template>

	<xsl:template match="comment">
		<span class="comment">
			<br/><xsl:value-of select="."/>
		</span>
	</xsl:template>
</xsl:stylesheet>