XSLT, . . XML wix "http://schemas.microsoft.com/wix/2006/wi", XSLT , , , , NO, wix.
XSLT ,
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wi="http://schemas.microsoft.com/wix/2006/wi">
, , . , , , :
<xsl:template match="wi:ComponentGroup[@Id='CG.WinSvcContent']/wi:Component/wi:File[contains(@Source,'Windows.Service.exe') and not(contains(@Source,'config'))]">
, , , , , , , . , , :
<xsl:template match="wi:ComponentGroup[@Id='CG.WinSvcContent']/wi:Component/wi:File[contains(@Source,'Windows.Service.exe') and not(contains(@Source,'config'))]">
<xsl:copy>
<xsl:attribute name="Id">Windows_Service_exe</xsl:attribute>
<xsl:copy-of select="@*[name()!='Id']"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
( xsl: apply-templates, , , , )
.
<xsl:template match="node[@Id=vIdToReplace]">
, "node()", "node" , "node" "node" , , , @Id vIdToReplace. vIdToReplace, . $vIdToReplace
<xsl:template match="node()[@Id=$vIdToReplace]">
! XSLT 1.0, . , XSLT 1.0. XSLT 2.0. :
<xsl:template match="node()[@Id=//wi:ComponentGroup[@Id='CG.WinSvcContent']/wi:Component[wi:File[contains(@Source,'Windows.Service.exe') and not(contains(@Source,'config'))]]/@Id]">
. , , , :
<xsl:key name="vIdToReplace"
match="wi:ComponentGroup[@Id='CG.WinSvcContent']/wi:Component[wi:File[contains(@Source,'Windows.Service.exe') and not(contains(@Source,'config'))]]"
use="@Id"/>
, , @Id
<xsl:template match="node()[key('vIdToReplace', @Id)]">
XSLT
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wi="http://schemas.microsoft.com/wix/2006/wi">
<xsl:key name="vIdToReplace"
match="wi:ComponentGroup[@Id='CG.WinSvcContent']/wi:Component[wi:File[contains(@Source,'Windows.Service.exe') and not(contains(@Source,'config'))]]"
use="@Id"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="node()[key('vIdToReplace', @Id)]">
<xsl:copy>
<xsl:attribute name="Id">C_Windows_Service_exe</xsl:attribute>
<xsl:copy-of select="@*[name()!='Id']"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="wi:ComponentGroup[@Id='CG.WinSvcContent']/wi:Component/wi:File[contains(@Source,'Windows.Service.exe') and not(contains(@Source,'config'))]">
<xsl:copy>
<xsl:attribute name="Id">Windows_Service_exe</xsl:attribute>
<xsl:copy-of select="@*[name()!='Id']"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
XML :
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
[...]
<Fragment>
<ComponentGroup Id="Windows.Service.Binaries">
<ComponentRef Id="C_Windows_Service_exe"/>
[...]
</ComponentGroup>
</Fragment>
[...]
<Fragment>
<ComponentGroup Id="CG.WinSvcContent">
<Component Id="C_Windows_Service_exe" Directory="TARGETDIR" Guid="{SOMEGUID}">
<File Id="Windows_Service_exe" Source="$(var.Windows.Service.TargetDir)\Windows.Service.exe"/>
</Component>
[...]
</ComponentGroup>
</Fragment>
[...]
</Wix>