-
Notifications
You must be signed in to change notification settings - Fork 0
/
msi.xsl
342 lines (306 loc) · 10.1 KB
/
msi.xsl
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:dt="urn:schemas-microsoft-com:datatypes">
<xsl:output method="html" />
<!-- =============================================== -->
<!-- Root Template -->
<!-- =============================================== -->
<xsl:template match="/">
<html>
<head>
<xsl:call-template name="script"/>
</head>
<body>
<h1>Windows Installer Database</h1>
<p><address>Generated by msi2xml (c) 2001-2002 <a href="mailto:[email protected]">Daniel Gehriger</a></address></p>
<hr/>
<!-- Summary Info -->
<xsl:apply-templates select="/msi/summary"/>
<hr/>
<!-- TOC -->
<a name="___TOC___"/>
<h2>Table of Contents</h2>
<xsl:for-each select="/msi/table[row]">
<a><xsl:attribute name="href">#<xsl:value-of select="@name"/></xsl:attribute>
<xsl:value-of select="@name"/>
</a>
<xsl:text> | </xsl:text>
</xsl:for-each>
<hr/>
<!-- Tables -->
<xsl:apply-templates select="/msi/table[row]"/>
</body>
</html>
</xsl:template>
<!-- =============================================== -->
<!-- Summary Information Template -->
<!-- =============================================== -->
<xsl:template match="/msi/summary">
<h2>Summary Information</h2>
<table>
<tr>
<td><b>Title:</b></td>
<td><xsl:value-of select="//summary/title"/></td>
</tr>
<tr>
<td><b>Subject:</b></td>
<td><xsl:value-of select="//summary/subject"/></td>
</tr>
<tr>
<td><b>Author:</b></td>
<td><xsl:value-of select="//summary/author"/></td>
</tr>
<tr>
<td><b>Keywords:</b></td>
<td><xsl:value-of select="//summary/keywords"/></td>
</tr>
<tr>
<td><b>Comments:</b></td>
<td><xsl:value-of select="//summary/comments"/></td>
</tr>
<tr>
<td><b>Revision Number:</b></td>
<td><xsl:value-of select="//summary/revnumber"/></td>
</tr>
<tr>
<td><b>Last Saved By:</b></td>
<td><xsl:value-of select="//summary/lastauthor"/></td>
</tr>
<tr>
<td><b>Last Saved Date/Time:</b></td>
<td><xsl:value-of select="//summary/lastsavedtm"/></td>
</tr>
</table>
</xsl:template>
<!-- =============================================== -->
<!-- Table Template -->
<!-- =============================================== -->
<xsl:template match="/msi/table">
<xsl:call-template name="tableTitle"/>
<table border="1">
<xsl:call-template name="tableHeader"/>
<tbody>
<xsl:for-each select="row">
<tr>
<xsl:apply-templates select="."/>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:template>
<!-- =============================================== -->
<!-- Table Template (numerically sorted) -->
<!-- =============================================== -->
<xsl:template match="/msi/table[col[1]/@key='yes' and substring(col[1]/@def, 1,1)='i']">
<xsl:call-template name="tableTitle"/>
<table border="1">
<xsl:call-template name="tableHeader"/>
<tbody>
<xsl:for-each select="row">
<xsl:sort data-type="number" select="td[1]"/>
<tr>
<xsl:apply-templates select="."/>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:template>
<!-- =============================================== -->
<!-- Table Template (With Sequence Number Sorting -->
<!-- =============================================== -->
<xsl:template match="/msi/table[col[3]='Sequence']">
<xsl:call-template name="tableTitle"/>
<table border="1">
<xsl:call-template name="tableHeader"/>
<tbody>
<xsl:for-each select="row">
<xsl:sort data-type="number" select="td[3]"/>
<tr>
<xsl:apply-templates select="."/>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:template>
<!-- =============================================== -->
<!-- Table Title Template -->
<!-- =============================================== -->
<xsl:template name="tableTitle">
<a>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
</a>
<h2><xsl:value-of select="@name"/></h2>
<!-- links -->
<xsl:if test="preceding-sibling::*[row][1]">
<a>
<xsl:attribute name="href">
#<xsl:value-of select="preceding-sibling::*[row][1]/@name"/>
</xsl:attribute>previous</a>
<xsl:text> | </xsl:text>
</xsl:if>
<a href="#___TOC___">TOC</a>
<xsl:if test="following-sibling::*[row][1]">
<xsl:text> | </xsl:text>
<a>
<xsl:attribute name="href">
#<xsl:value-of select="following-sibling::*[row][1]/@name"/>
</xsl:attribute>next
</a>
</xsl:if>
</xsl:template>
<!-- =============================================== -->
<!-- Table Column Header Template -->
<!-- =============================================== -->
<xsl:template name="tableHeader">
<thead>
<xsl:for-each select="col">
<th>
<xsl:attribute name="onmouseover">
Tip '<xsl:value-of select="parent::node()/@name"/>','<xsl:value-of select="."/>'
</xsl:attribute>
<code><xsl:value-of select="."/></code>
<xsl:if test="@key='yes'">
<xsl:text> (key)</xsl:text>
</xsl:if>
<br><xsl:value-of select="@def"/></br>
</th>
</xsl:for-each>
</thead>
</xsl:template>
<!-- =============================================== -->
<!-- Table Row Template -->
<!-- =============================================== -->
<xsl:template match="/msi/table/row">
<xsl:for-each select="td">
<td>
<xsl:variable name="pos" select="position()"/>
<xsl:variable name="col" select="ancestor::table/col[$pos]"/>
<xsl:attribute name="onmouseover">
Tip '<xsl:value-of select="ancestor::table/@name"/>','<xsl:value-of select="$col"/>'
</xsl:attribute>
<xsl:choose>
<xsl:when test=".=''">
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:when test="substring($col, string-length($col), 1)='_'">
<a><xsl:attribute name="href">#<xsl:value-of select="substring($col, 1, string-length($col)-1)"/>.<xsl:value-of select="."/></xsl:attribute>
<xsl:apply-templates select="."/>
</a>
</xsl:when>
<xsl:when test="$col/@key='yes'">
<a><xsl:attribute name="name"><xsl:value-of select="ancestor::table/@name"/>.<xsl:value-of select="."/></xsl:attribute>
<xsl:apply-templates select="."/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
</xsl:template>
<!-- =============================================== -->
<!-- Table Field Template -->
<!-- =============================================== -->
<xsl:template match="/msi/table/row/td">
<xsl:choose>
<!-- external reference -->
<xsl:when test="@href">
<i>binary stream
<a><xsl:attribute name="href">
<xsl:value-of select="@href"/>
</xsl:attribute>save to disk
</a>
</i>
</xsl:when>
<!-- NULL -->
<xsl:when test=". = ''">
<i>Null</i>
</xsl:when>
<!-- base64 encoded binary data -->
<xsl:when test="@dt:dt='bin.base64'">
<i>binary stream
<xsl:if test="@md5">
(<a>
<xsl:attribute name="href">
#<xsl:value-of select="ancestor::table/@name"/>
</xsl:attribute>
<xsl:attribute name="onClick">
WriteBinData('<xsl:value-of select="@md5"/>')
</xsl:attribute>save to disk</a>)
</xsl:if>
</i>
</xsl:when>
<!-- default -->
<xsl:otherwise>
<code><xsl:value-of select="."/></code>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- =============================================== -->
<!-- Script Template -->
<!-- =============================================== -->
<xsl:template name="script">
<script language="vbscript" type="text/vbscript">
<![CDATA[
<!--
Function Tip(strTable, strColumn)
strQuery = "/msi/table[@name='_Validation']/" & _
"row[td[0]='" & strTable & "' and " & _
"td[1]='" & strColumn & "']/td[9]"
Dim oNode
Set oNode = document.XMLDocument.selectSingleNode(strQuery)
If oNode Is Nothing Then
window.event.srcElement.title = strQuery
Else
window.event.srcElement.title = oNode.nodeTypedValue
End If
End Function
Function WriteBinData(strMD5)
WriteBinData = False
Dim oNode
Set oNode = document.XMLDocument.selectSingleNode("//td[@md5='" & strMD5 & "']")
If oNode Is Nothing Then
MsgBox "Unable to find binary data."
Exit Function
End If
Dim strSaveTo
If document.location.protocol = "file:" Then
strSaveTo = document.location.pathname
strSaveTo = Mid(strSaveTo, 2, InStrRev(strSaveTo, "\") - 1)
End If
strSaveTo = Inputbox("Save binary stream as:", "Save Binary File As", strSaveTo)
If strSaveTo = "" Then
Exit Function
End If
Dim arrBuffer
arrBuffer = oNode.nodeTypedValue
Dim sTemp
nMax = Len(arrBuffer)
With CreateObject("Scripting.FileSystemObject")
With .CreateTextFile(strSaveTo, True, False)
Do Until Len(arrBuffer) = 0
window.status = "Percentage completed: " & CStr(CInt(100 - (100 * Len(arrBuffer) / nMax)))
ReDim sOut(5000 - 1)
sTemp = Left(arrBuffer, 5000)
For j = 0 To 5000 - 1
sOut(j) = Chr(AscB(LeftB(sTemp,1)))
sTemp = MidB(sTemp,2)
if sTemp = "" Then Exit For
Next ' j
.Write Join(sOut, "")
arrBuffer = MidB(arrBuffer, 5000 + 1)
Loop
End With ' Output file
End With ' FSO
window.status = "Done."
End Function
-->
]]>
</script>
</xsl:template>
</xsl:stylesheet>