File: KDBX_Tabular_HTML.xsl

package info (click to toggle)
keepass2 2.41%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,892 kB
  • sloc: cs: 103,600; xml: 5,869; cpp: 308; sh: 48; makefile: 46
file content (105 lines) | stat: -rw-r--r-- 3,215 bytes parent folder | download | duplicates (2)
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
104
105
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="KDBX_Common.xsl" />
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="no" />

<xsl:template match="/">
	<xsl:apply-templates select="KeePassFile" />
</xsl:template>

<xsl:template match="KeePassFile">
	<xsl:copy-of select="$HtmlHeader" />
	<head><xsl:copy-of select="$nl" />
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><xsl:copy-of select="$nl" />
		<xsl:apply-templates select="Meta" />
		<xsl:copy-of select="$DocStyle" />
	</head><xsl:copy-of select="$nl" />
	<body><xsl:copy-of select="$nl" />

	<xsl:apply-templates select="Root" />

	</body><xsl:copy-of select="$nl" />
	<xsl:copy-of select="$HtmlFooter" />
</xsl:template>

<xsl:template match="Meta">
	<title>
		<xsl:if test="DatabaseName != ''">
			<xsl:value-of select="DatabaseName" />
		</xsl:if>
		<xsl:if test="DatabaseName = ''">
			<xsl:text>Database</xsl:text>
		</xsl:if>
	</title><xsl:copy-of select="$nl" />
</xsl:template>

<xsl:template match="Root">
	<xsl:apply-templates select="Group" />
</xsl:template>

<xsl:template match="Group">
	<h2><xsl:value-of select="Name" /></h2><xsl:copy-of select="$nl" />

	<table class="tablebox"><xsl:copy-of select="$nl" />
	<tr><xsl:copy-of select="$nl" />
	<th style="width: 20%;">Title</th>
		<xsl:copy-of select="$nl" />
	<th style="width: 20%;">User Name</th>
		<xsl:copy-of select="$nl" />
	<th style="width: 20%;">Password</th>
		<xsl:copy-of select="$nl" />
	<th style="width: 20%;">URL</th>
		<xsl:copy-of select="$nl" />
	<th style="width: 20%;">Notes</th>
		<xsl:copy-of select="$nl" />
	</tr><xsl:copy-of select="$nl" />

	<xsl:apply-templates select="Entry" />

	</table><xsl:copy-of select="$nl" />

	<xsl:for-each select="Group">
		<xsl:text disable-output-escaping="yes"><![CDATA[<p><small>&nbsp;</small></p>]]></xsl:text>
		<xsl:copy-of select="$nl" />
		<xsl:apply-templates select="." />
	</xsl:for-each>
</xsl:template>

<xsl:template match="Entry">
	<tr>
	<td>
		<xsl:for-each select="String[(Key = 'Title') and (Value != '')]">
			<xsl:value-of select="Value" />
		</xsl:for-each>
	</td><xsl:copy-of select="$nl" />
	<td>
		<xsl:for-each select="String[(Key = 'UserName') and (Value != '')]">
			<xsl:value-of select="Value" />
		</xsl:for-each>
	</td><xsl:copy-of select="$nl" />
	<td>
		<xsl:for-each select="String[(Key = 'Password') and (Value != '')]">
			<code><xsl:value-of select="Value" /></code>
		</xsl:for-each>
	</td><xsl:copy-of select="$nl" />

	<td>
		<xsl:for-each select="String[(Key = 'URL') and (Value != '')]">
			<xsl:element name="a">
				<xsl:attribute name="href">
					<xsl:value-of select="Value" />
				</xsl:attribute>
				<xsl:value-of select="Value" />
			</xsl:element>
		</xsl:for-each>
	</td><xsl:copy-of select="$nl" />

	<td>
		<xsl:for-each select="String[(Key = 'Notes') and (Value != '')]">
			<xsl:value-of select="Value" />
		</xsl:for-each>
	</td><xsl:copy-of select="$nl" />
	</tr><xsl:copy-of select="$nl" />
</xsl:template>

</xsl:stylesheet>