I am building a Wix installer that is based on a set of auto-generated XML files (I use HEAT to harvest folder content). I need to exclude certain files from a resulting XML, for example, from this fragment I want to exclude a file “Web.config”:
<Component Id="cmp87E809324190AF5E85315B10C397DB8F"
Directory="Content"
Guid="{4210C091-E16F-45EA-9005-A7487CF6AC69}">
<File Id="fil13DABBB8A7FACF8E81FE69FD2464DE48"
Source="$(var.ProjectDir)\MyService.svc" />
</Component>
<Component Id="cmp276C007DCB38D3C2E4DA41DFDD8F5CED"
Directory="Content"
Guid="{A01BE50E-3B00-40EF-96EB-D48AED1F6259}">
<File Id="fil527A2DD913A88F35BD2B90F10029FB32"
Source="$(var.ProjectDir)\Web.config" />
</Component>
I apply the following transformation:
<!-- Identity template -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<!-- exclude files -->
<xsl:template match="wix:Component/wix:File[
@Source='$(var.ProjectDir)\Web.config'
]">
</xsl:template>
Unfortunately it only removes the “File” element (the one it matches), I would like to remove the parent element (“Component”) for the matched “File” sub-element. This must be relatively easy in XSLT, but I haven’t figured it out.
Thanks in advance
You should use:
Namespaces are missing in your sample XML, so you can add them yourself.