11<?xml version =" 1.0" encoding =" utf-8" ?>
2- <xsl : stylesheet version =" 1.0"
3- xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" >
4- <!-- Convert KeePass XML (2.x) format ClickStudios PasswordState Import
5- format
6- Toni Comerma September 2013
7- Copyright (c) 2013 Toni Comerma - Televisió de Catalunya.
8- GNU GENERAL PUBLIC LICENSE - See attached License File
9-
10- Based on LiosK/keepass2keeper.xsl (https://gist.github.com/LiosK/388889)
11- -->
12-
13- <!-- Config Section -->
14- <xsl : param name =" PasswordListID" >14</xsl : param >
15- <xsl : param name =" AccountType" />
16-
17-
18- <!-- Code Section -->
19-
20- <xsl : variable name =" cometa" >"</xsl : variable >
21-
2+ <xsl : stylesheet version =" 1.0" xmlns : xsl =" http://www.w3.org/1999/XSL/Transform" >
223 <xsl : output method =" text" encoding =" utf-8" />
4+ <xsl : variable name =" cometa" >"</xsl : variable >
235
246 <xsl : template match =" /" >
257 <!-- Header Row -->
26- <xsl : text >PasswordListID,Title,UserName,Description,AccountType,Notes,URL,Password,ExpiryDate,GenericField1,GenericField2,GenericField3,GenericField4,GenericField5,GenericField6,GenericField7,GenericField8,GenericField9,GenericField10
27- </xsl : text >
8+ <xsl : text >Title,UserName,Password,Url,Notes </xsl : text >
289 <xsl : apply-templates select =" /KeePassFile/Root/Group" />
2910 </xsl : template >
3011
12+ <!-- These groups will be ignored -->
13+ <xsl : template match =" Group[Name='Recycle Bin']" />
14+
3115 <xsl : template match =" Group" >
3216 <xsl : param name =" parent" select =" '/'" />
3317 <xsl : variable name =" current" select =" concat($parent, Name)" />
4327 </xsl : apply-templates >
4428 </xsl : template >
4529
46-
4730 <xsl : template match =" Entry" >
4831 <xsl : param name =" group" />
4932
5639 <xsl : with-param name =" by" select =" concat($cometa,$cometa)" />
5740 </xsl : call-template >
5841 </xsl : if >
42+ <xsl : text >From KeePass conversion, Group: </xsl : text >
43+ <xsl : value-of select =" $group" />
44+ <xsl : text >, Icon: </xsl : text >
45+ <xsl : call-template name =" iconName" >
46+ <xsl : with-param name =" iconId" select =" IconID" />
47+ </xsl : call-template >
5948 </xsl : variable >
6049
6150 <!-- Escape Double quotes in password field -->
6958 </xsl : if >
7059 </xsl : variable >
7160
72- <!-- Escape Double quotes in password field (yes, someone put quotes in that field too)-->
61+ <!-- Escape Double quotes in URL field (yes, someone put quotes in that field too)-->
7362 <xsl : variable name =" url" >
7463 <xsl : if test =" String[Key='URL']/Value!=''" >
7564 <xsl : call-template name =" string-replace-all" >
9281 </xsl : choose >
9382 </xsl : variable >
9483
95- <!-- Fix wrong dates (year 2999) -->
96- <xsl : variable name =" date" >
97- <xsl : call-template name =" replaceDate" >
98- <xsl : with-param name =" value" select =" Times/ExpiryTime" />
99- </xsl : call-template >
100- </xsl : variable >
101-
102- <!-- put tab-separated fields: Title, UserName, Password, Notes, Group,
103- URL, JSON -->
84+ <!-- put CSV fields: Title, UserName, Password, Group, URL, Notes -->
10485 <xsl : text >"</xsl : text >
105- <xsl : value-of select =" $PasswordListID" />
106- <xsl : text >","</xsl : text >
10786 <xsl : value-of select =" $title" />
10887 <xsl : text >","</xsl : text >
10988 <xsl : value-of select =" String[Key='UserName']/Value" />
11089 <xsl : text >","</xsl : text >
111- <xsl : value-of select =" $group" />
112- <xsl : text >","</xsl : text >
113- <xsl : value-of select =" $AccountType" />
114- <xsl : text >","</xsl : text >
115- <xsl : value-of select =" $notes" />
90+ <xsl : value-of select =" $password" />
11691 <xsl : text >","</xsl : text >
11792 <xsl : value-of select =" $url" />
11893 <xsl : text >","</xsl : text >
119- <xsl : value-of select =" $password" />
120- <xsl : text >","</xsl : text >
121- <xsl : value-of select =" $date" />
94+ <xsl : value-of select =" $notes" />
12295 <xsl : text >" </xsl : text >
12396 </xsl : template >
12497
165138 </xsl : choose >
166139 </xsl : template >
167140
168- <xsl : template name =" replaceDate " >
169- <xsl : param name =" value " />
141+ <xsl : template name =" iconName " >
142+ <xsl : param name =" iconId " />
170143 <xsl : choose >
171- <xsl : when test =" $value!=''" >
172- <xsl : choose >
173- <xsl : when test =" substring($value,1,4) > 2020" >
174- <xsl : text >2020-12-31T23:59:59Z</xsl : text >
175- </xsl : when >
176- <xsl : otherwise >
177- <xsl : value-of select =" $value" />
178- </xsl : otherwise >
179- </xsl : choose >
180- </xsl : when >
181- <xsl : otherwise >
182- <xsl : value-of select =" $value" />
183- </xsl : otherwise >
144+ <xsl : when test =" $iconId=0" >Default Key</xsl : when >
145+ <xsl : when test =" $iconId=43" >Trash Bin</xsl : when >
146+ <xsl : when test =" $iconId=45" >Red X</xsl : when >
147+ <xsl : otherwise >
148+ <xsl : value-of select =" $iconId" />
149+ </xsl : otherwise >
184150 </xsl : choose >
185151 </xsl : template >
152+
186153</xsl : stylesheet >
0 commit comments