我在WIX安裝中使用收穫文件文件上的xslt變換。我試圖將某些目錄中的所有文件標記爲永久文件。爲了做到這一點,我必須做一個包含,以查看文件夾名稱是否在源屬性中。下面是節點之一,然後是變換。任何幫助將不勝感激。XSLT:根據包含特定字符串的子屬性值將屬性添加到父項
<Component Id="cmpE4293ADC65367393D7A7630023A43F89" Directory="dirAFEA15D2A28EA2E6080FAD1EE1935E0A" Guid="{691DB98F-E5F4-4979-B2E5-63E14AF8A328}">
<File Id="filE11EC7DCDC230815BECFE0925B1F3DC4" KeyPath="yes" Source="$(var.publishDir)\WebConfig\appSettings.config" />
</Component>
<?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="http://schemas.microsoft.com/wix/2006/wi"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="wix">
<xsl:template match="wix:Wix">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="wix:Component">
<!-- Just copy the tag itself -->
<xsl:copy>
<xsl:variable name="fvsys" >
<xsl:value-of select="node()/File/@Source"/>
</xsl:variable>
<!-- Copy all attributes -->
<xsl:apply-templates select="@*" />
<!-- Here comes the distinction: if you find our special component, do some special things -->
<xsl:choose>
<!-- Note that the string is translated to all lower case, so you don't have to care about being case sensitive or not -->
<xsl:when test="contains($fvsys, 'WebConfig')">
<!-- Here we will add the Permanent-attribute to this very special component -->
<xsl:attribute name="Permanent">yes</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:choose>
<!-- Note that the string is translated to all lower case, so you don't have to care about being case sensitive or not -->
<xsl:when test="contains($fvsys, 'DocumentConversions')">
<!-- Here we will add the Permanent-attribute to this very special component -->
<xsl:attribute name="Permanent">yes</xsl:attribute>
</xsl:when>
</xsl:choose>
<!-- Now take the rest of the inner tag -->
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
感謝您的回答,我使用了下面列出的內容。 – 2014-09-29 11:15:00