-
Notifications
You must be signed in to change notification settings - Fork 1
/
genDir.xsl
62 lines (58 loc) · 2.85 KB
/
genDir.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
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="/msi/table[@name='Directory']">
<Fragment>
<xsl:for-each select="row">
<xsl:choose>
<xsl:when test="td[2] != ''">
<DirectoryRef>
<xsl:attribute name="Id">
<xsl:value-of select="td[2]" /></xsl:attribute>
<Directory>
<xsl:attribute name="Id">
<xsl:value-of select="td[1]" /></xsl:attribute>
<xsl:choose>
<xsl:when test="contains(td[3],':')">
<xsl:choose>
<xsl:when test="contains(td[3],'|')">
<xsl:attribute name="ShortName">
<xsl:value-of select="substring-before(substring-after(td[3],':'),'|')" /></xsl:attribute>
<xsl:attribute name="Name">
<xsl:value-of select="substring-after(td[3],'|')" /></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="Name">
<xsl:value-of select="substring-after(td[3],':')" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="contains(td[3],'|')">
<xsl:attribute name="Name">
<xsl:value-of select="substring-after(td[3],'|')" /></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="Name">
<xsl:value-of select="td[3]" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</Directory>
</DirectoryRef>
</xsl:when>
<xsl:otherwise>
<Directory>
<xsl:attribute name="Id">
<xsl:value-of select="td[1]" /></xsl:attribute>
<xsl:attribute name="Name">
<xsl:value-of select="td[3]" /></xsl:attribute>
</Directory>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</Fragment>
</xsl:template>
</xsl:stylesheet>