-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathwrite3.xsl
416 lines (383 loc) · 16.4 KB
/
write3.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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"
xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1"
xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2"
version="1.0">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="trust-file"/>
<xsl:variable name="trust" select="document($trust-file)"/>
<xsl:template match="AssemblyManifest">
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd"
manifestVersion="1.0"
>
<xsl:apply-templates select="AssemblyIdentity" mode="v1"/>
<xsl:call-template name="assembly-manifest"/>
<xsl:apply-templates select="AssemblyReferences/AssemblyReference"/>
<xsl:apply-templates select="FileReferences/FileReference"/>
<xsl:apply-templates select="ExternalProxyStubs/ProxyStub" mode="external"/>
</assembly>
</xsl:template>
<xsl:template match="ApplicationManifest[@IsClickOnceManifest='false']">
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd"
manifestVersion="1.0"
>
<xsl:apply-templates select="AssemblyIdentity" mode="v1"/>
<xsl:call-template name="assembly-manifest"/>
<!-- Application Trust -->
<xsl:if test="$trust">
<xsl:copy-of select="$trust"/>
</xsl:if>
<xsl:apply-templates select="AssemblyReferences/AssemblyReference"/>
<xsl:apply-templates select="FileReferences/FileReference"/>
<xsl:apply-templates select="ExternalProxyStubs/ProxyStub" mode="external"/>
</assembly>
</xsl:template>
<xsl:template match="ApplicationManifest[@IsClickOnceManifest='true']">
<asmv1:assembly
xmlns="urn:schemas-microsoft-com:asm.v2"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1"
xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd"
manifestVersion="1.0"
>
<xsl:apply-templates select="AssemblyIdentity" mode="winxp-hack"/>
<xsl:call-template name="application-manifest"/>
<xsl:apply-templates select="AssemblyReferences/AssemblyReference"/>
<xsl:apply-templates select="FileReferences/FileReference"/>
<xsl:apply-templates select="FileAssociations/FileAssociation"/>
<xsl:apply-templates select="ExternalProxyStubs/ProxyStub" mode="external"/>
</asmv1:assembly>
</xsl:template>
<xsl:template match="DeployManifest">
<asmv1:assembly
xmlns="urn:schemas-microsoft-com:asm.v2"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd"
manifestVersion="1.0"
>
<xsl:apply-templates select="AssemblyIdentity" mode="v1"/>
<xsl:call-template name="deploy-manifest"/>
<xsl:if test="count(CompatibleFrameworks)>0">
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
<xsl:apply-templates select="CompatibleFrameworks/CompatibleFramework"/>
</compatibleFrameworks>
</xsl:if>
<xsl:for-each select="AssemblyReferences/AssemblyReference"> <!-- expecting only one match -->
<xsl:call-template name="application-reference"/>
</xsl:for-each>
<xsl:apply-templates select="FileReferences/FileReference"/>
</asmv1:assembly>
</xsl:template>
<xsl:attribute-set name="identity-attributes">
<xsl:attribute name="name"><xsl:value-of select="@Name"/></xsl:attribute>
<xsl:attribute name="version"><xsl:value-of select="@Version"/></xsl:attribute>
<xsl:attribute name="publicKeyToken"><xsl:value-of select="@PublicKeyToken"/></xsl:attribute>
<xsl:attribute name="language"><xsl:value-of select="@Culture"/></xsl:attribute>
<xsl:attribute name="processorArchitecture"><xsl:value-of select="@ProcessorArchitecture"/></xsl:attribute>
<xsl:attribute name="type"><xsl:value-of select="@Type"/></xsl:attribute>
</xsl:attribute-set>
<!--
WinXP & Win2K3 requires this element to be declared with the asmv1 qualifier.
Setting the default namespace will not work!
This is a quirk of the native loader on downlevel OS.
-->
<xsl:template match="AssemblyIdentity" mode="winxp-hack">
<xsl:element name="asmv1:assemblyIdentity" use-attribute-sets="identity-attributes"/>
</xsl:template>
<xsl:template match="AssemblyIdentity" mode="v1">
<xsl:element name="assemblyIdentity" use-attribute-sets="identity-attributes" namespace="urn:schemas-microsoft-com:asm.v1"/>
</xsl:template>
<xsl:template match="AssemblyIdentity" mode="v2">
<xsl:element name="assemblyIdentity" use-attribute-sets="identity-attributes" namespace="urn:schemas-microsoft-com:asm.v2"/>
</xsl:template>
<xsl:template match="EntryPointIdentity">
<xsl:element name="assemblyIdentity" use-attribute-sets="identity-attributes" namespace="urn:schemas-microsoft-com:asm.v2"/>
</xsl:template>
<xsl:template name="assembly-manifest">
<xsl:if test="string-length(@Description)>0">
<description>
<xsl:value-of select="@Description"/>
</description>
</xsl:if>
</xsl:template>
<xsl:template name="application-manifest">
<!-- Description -->
<xsl:if test="string-length(@Description)>0 or string-length(@IconFile)>0 or string-length(@Publisher)>0 or string-length(@Product)>0 or string-length(@SupportUrl)>0 or string-length(@SuiteName)>0 or string-length(@ErrorReportUrl)>0">
<description asmv2:iconFile="{@IconFile}"
asmv2:publisher="{@Publisher}"
co.v1:suiteName="{@SuiteName}"
asmv2:product="{@Product}"
asmv2:supportUrl="{@SupportUrl}"
co.v1:errorReportUrl="{@ErrorReportUrl}">
<xsl:value-of select="@Description"/>
</description>
</xsl:if>
<application xmlns="urn:schemas-microsoft-com:asm.v2"/>
<!-- Application Startup -->
<xsl:choose>
<xsl:when test="EntryPointIdentity">
<entryPoint xmlns="urn:schemas-microsoft-com:asm.v2">
<xsl:apply-templates select="EntryPointIdentity"/>
<commandLine
file="{@EntryPointPath}"
parameters="{@EntryPointParameters}"
/>
<xsl:if test="@HostInBrowser='true'">
<hostInBrowser xmlns="urn:schemas-microsoft-com:asm.v3"/>
</xsl:if>
</entryPoint>
</xsl:when>
<xsl:when test="@HostInBrowser='true'">
<entryPoint xmlns="urn:schemas-microsoft-com:asm.v2">
<xsl:if test="@HostInBrowser='true'">
<hostInBrowser xmlns="urn:schemas-microsoft-com:asm.v3"/>
</xsl:if>
</entryPoint>
</xsl:when>
<xsl:otherwise>
<entryPoint xmlns="urn:schemas-microsoft-com:asm.v2">
<co.v1:customHostSpecified />
</entryPoint>
</xsl:otherwise>
</xsl:choose>
<!-- Manifest Trust -->
<xsl:if test="@UseApplicationTrust='true'">
<co.v1:useManifestForTrust />
</xsl:if>
<!-- Application Trust -->
<xsl:if test="$trust">
<xsl:copy-of select="$trust"/>
</xsl:if>
<!-- OS dependency -->
<xsl:if test="string-length(@OSMajor)>0">
<dependency xmlns="urn:schemas-microsoft-com:asm.v2">
<dependentOS supportUrl="{@OSSupportUrl}" description="{@OSDescription}">
<osVersionInfo>
<os majorVersion="{@OSMajor}" minorVersion="{@OSMinor}" buildNumber="{@OSBuild}" servicePackMajor="{@OSRevision}"/>
</osVersionInfo>
</dependentOS>
</dependency>
</xsl:if>
</xsl:template>
<xsl:template name="deploy-manifest">
<!-- Description -->
<description xmlns="urn:schemas-microsoft-com:asm.v1"
asmv2:publisher="{@Publisher}"
co.v1:suiteName="{@SuiteName}"
asmv2:product="{@Product}"
asmv2:supportUrl="{@SupportUrl}"
co.v1:errorReportUrl="{@ErrorReportUrl}"
>
<xsl:value-of select="@Description"/>
</description>
<!-- Application Updates -->
<deployment xmlns="urn:schemas-microsoft-com:asm.v2"
install="{@Install}"
disallowUrlActivation="{@DisallowUrlActivation}"
mapFileExtensions="{@MapFileExtensions}"
minimumRequiredVersion="{@MinimumRequiredVersion}"
trustURLParameters="{@TrustUrlParameters}"
co.v1:createDesktopShortcut="{@CreateDesktopShortcut}"
>
<xsl:if test="@Install='true' and @UpdateEnabled='true'">
<subscription>
<update>
<xsl:choose>
<xsl:when test="@UpdateMode='Foreground'">
<beforeApplicationStartup/>
</xsl:when>
<xsl:otherwise>
<expiration maximumAge="{@UpdateInterval}" unit="{@UpdateUnit}"/>
</xsl:otherwise>
</xsl:choose>
</update>
</subscription>
</xsl:if>
<xsl:if test="string-length(@DeploymentUrl)>0">
<deploymentProvider codebase="{@DeploymentUrl}"/>
</xsl:if>
</deployment>
</xsl:template>
<!-- This is the <dependency> element for referencing the ApplicationManifest (.exe.manifest) from the DeployManifest (.application) -->
<xsl:template name="application-reference">
<dependency xmlns="urn:schemas-microsoft-com:asm.v2">
<dependentAssembly
dependencyType="install"
codebase="{@Path}"
size="{@Size}"
>
<xsl:apply-templates select="AssemblyIdentity" mode="v2"/>
<xsl:call-template name="hash">
<xsl:with-param name="value"><xsl:value-of select="@Hash"/></xsl:with-param>
</xsl:call-template>
</dependentAssembly>
</dependency>
</xsl:template>
<!-- Must put native <dependency> elements in the asmv1 namespace -->
<xsl:template match="AssemblyReference[@IsNative='true' and @IsPrerequisite='false']">
<dependency optional="{@IsOptional}" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly
asmv2:dependencyType="install"
asmv2:codebase="{@Path}"
asmv2:size="{@Size}"
asmv2:group="{@Group}"
>
<xsl:apply-templates select="AssemblyIdentity" mode="v1"/>
<xsl:call-template name="hash">
<xsl:with-param name="value"><xsl:value-of select="@Hash"/></xsl:with-param>
</xsl:call-template>
</dependentAssembly>
</dependency>
</xsl:template>
<xsl:template match="AssemblyReference[@IsNative='true' and @IsPrerequisite='true']">
<dependency xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly
asmv2:dependencyType="preRequisite"
>
<xsl:apply-templates select="AssemblyIdentity" mode="v1"/>
</dependentAssembly>
</dependency>
</xsl:template>
<!-- Other <dependency> elements go in the asmv2 namespace -->
<xsl:template match="AssemblyReference[@IsNative='false' and @IsPrerequisite='false']">
<dependency optional="{@IsOptional}" xmlns="urn:schemas-microsoft-com:asm.v2">
<dependentAssembly
dependencyType="install"
allowDelayedBinding="true"
codebase="{@Path}"
size="{@Size}"
group="{@Group}"
>
<xsl:apply-templates select="AssemblyIdentity" mode="v2"/>
<xsl:call-template name="hash">
<xsl:with-param name="value"><xsl:value-of select="@Hash"/></xsl:with-param>
</xsl:call-template>
</dependentAssembly>
</dependency>
</xsl:template>
<xsl:template match="AssemblyReference[@IsNative='false' and @IsPrerequisite='true']">
<dependency xmlns="urn:schemas-microsoft-com:asm.v2">
<dependentAssembly
dependencyType="preRequisite"
allowDelayedBinding="true"
>
<xsl:apply-templates select="AssemblyIdentity" mode="v2"/>
</dependentAssembly>
</dependency>
</xsl:template>
<xsl:template match="FileReference[not(ComClasses or WindowClasses)]">
<file xmlns="urn:schemas-microsoft-com:asm.v2"
name="{@Path}"
size="{@Size}"
group="{@Group}"
optional="{@IsOptional}"
writeableType="{@WriteableType}"
>
<xsl:call-template name="hash">
<xsl:with-param name="value"><xsl:value-of select="@Hash"/></xsl:with-param>
</xsl:call-template>
</file>
</xsl:template>
<xsl:template match="FileReference[ComClasses or WindowClasses]">
<file xmlns="urn:schemas-microsoft-com:asm.v1"
name="{@Path}"
asmv2:size="{@Size}"
asmv2:group="{@Group}"
asmv2:optional="{@IsOptional}"
asmv2:writeableType="{@WriteableType}"
>
<xsl:call-template name="hash">
<xsl:with-param name="value"><xsl:value-of select="@Hash"/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="isolation"/>
</file>
</xsl:template>
<xsl:template name="hash">
<xsl:param name="value"/>
<xsl:if test="$value and string-length($value)>0">
<hash xmlns="urn:schemas-microsoft-com:asm.v2">
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"/>
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256"/>
<dsig:DigestValue><xsl:value-of select="$value"/></dsig:DigestValue>
</hash>
</xsl:if>
</xsl:template>
<xsl:template name="isolation">
<xsl:apply-templates select="TypeLibs/TypeLib"/>
<xsl:apply-templates select="ComClasses/ComClass"/>
<xsl:apply-templates select="WindowClasses/WindowClass"/>
<xsl:apply-templates select="ProxyStubs/ProxyStub" mode="internal"/>
</xsl:template>
<xsl:template match="TypeLib">
<typelib xmlns="urn:schemas-microsoft-com:asm.v1"
tlbid="{@Tlbid}"
version="{@Version}"
helpdir="{@HelpDir}"
resourceid="{@ResourceId}"
flags="{@Flags}"/>
</xsl:template>
<xsl:template match="ComClass">
<comClass xmlns="urn:schemas-microsoft-com:asm.v1"
clsid="{@Clsid}"
threadingModel="{@ThreadingModel}"
tlbid="{@Tlbid}"
progid="{@Progid}"
description="{@Description}"/>
</xsl:template>
<xsl:template match="WindowClass">
<windowClass xmlns="urn:schemas-microsoft-com:asm.v1"
versioned="{@Versioned}"
>
<xsl:value-of select="@Name"/>
</windowClass>
</xsl:template>
<xsl:template match="ProxyStub" mode="internal">
<comInterfaceProxyStub xmlns="urn:schemas-microsoft-com:asm.v1"
name="{@Name}"
iid="{@Iid}"
numMethods="{@NumMethods}"
baseInterface="{@BaseInterface}"
tlbid="{@Tlbid}"/>
</xsl:template>
<xsl:template match="ProxyStub" mode="external">
<comInterfaceExternalProxyStub xmlns="urn:schemas-microsoft-com:asm.v1"
name="{@Name}"
iid="{@Iid}"
numMethods="{@NumMethods}"
baseInterface="{@BaseInterface}"
tlbid="{@Tlbid}"/>
</xsl:template>
<xsl:template match="FileAssociation">
<fileAssociation xmlns="urn:schemas-microsoft-com:clickonce.v1"
extension="{@Extension}"
description="{@Description}"
progid="{@Progid}"
defaultIcon="{@DefaultIcon}"/>
</xsl:template>
<xsl:template match="CompatibleFramework">
<framework xmlns="urn:schemas-microsoft-com:clickonce.v2"
targetVersion="{@Version}"
profile="{@Profile}"
supportedRuntime="{@SupportedRuntime}"/>
</xsl:template>
</xsl:stylesheet>