|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="wix:Wix">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="wix:Component/wix:File[substring(@Source,string-length(@Source)-3)='.dll' or substring(@Source,string-length(@Source)-3)='.exe']">
<xsl:variable name="lastslashindex">
<xsl:call-template name="lastIndexOf">
<xsl:with-param name="string" select="@Source" />
<xsl:with-param name="char" select="'\'" />
</xsl:call-template>
</xsl:variable>
<xsl:copy>
<xsl:apply-templates select="@*" />
<netfx:NativeImage Priority="1">
<xsl:attribute name="Id">
<xsl:value-of select="$lastslashindex"/>
</xsl:attribute>
</netfx:NativeImage>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template name="lastIndexOf">
<!-- declare that it takes two parameters - the string and the char -->
<xsl:param name="string" />
<xsl:param name="char" />
<xsl:choose>
<!-- if the string contains the character... -->
<xsl:when test="contains($string, $char)">
<!-- call the template recursively... -->
<xsl:call-template name="lastIndexOf">
<!-- with the string being the string after the character
-->
<xsl:with-param name="string"
select="substring-after($string, $char)" />
<!-- and the character being the same as before -->
<xsl:with-param name="char" select="$char" />
</xsl:call-template>
</xsl:when>
<!-- otherwise, return the value of the string -->
<xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Mike Carlisle - Technical Architect with over 20 years experience in a wide range of technologies.
@TheCodeKing