I'm a XSL newb and have really trouble understanding the syntax. What I'm trying to achieve is to remove a node from the xml and its referenced node. This xml is build by running Heatdirectory, a tool provided with WIX Installer. So everything in the file is created dynamically. The one thing I know about the file, is the name of the file I want to remove the reference to.
This is and example XML:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="InstallFolder">
<Component Id="cmpAEC985F4FAA50E51011E84E93A32F283" Guid="{3574FFF9-F47D-4A3F-A975-64D76546068A}">
<File Id="fil9C01928D57F128482FD2A78A209FBF95" KeyPath="yes" Source="$(var.SourcePath)\AppSettings.config" />
</Component>
<Component Id="cmp10AE81284551BB54849628AE519965C7" Guid="{CF245728-B329-454E-A305-BE33FC818572}">
<File Id="fil3F1ECB9AAE6412D0FDF9577B44764BA9" KeyPath="yes" Source="$(var.SourcePath)\CsvHelper.dll" />
</Component>
<Component Id="cmp596F6F97E366DDB8E0770EC1550C6CB5" Guid="{D8E5EF9E-CB20-4C40-BD02-D79364EC6518}">
<File Id="filE48072B3494220F703E4B206DF9D2664" KeyPath="yes" Source="$(var.SourcePath)\CsvHelper.pdb" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="FileComponents">
<ComponentRef Id="cmpAEC985F4FAA50E51011E84E93A32F283" />
<ComponentRef Id="cmp10AE81284551BB54849628AE519965C7" />
<ComponentRef Id="cmp596F6F97E366DDB8E0770EC1550C6CB5" />
</ComponentGroup>
</Fragment>
</Wix>
And this is my XSLT that removes the Component that I want to remove.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="wix:Component[contains(wix:File/@Source,'CsvHelper.pdb')]"/>
</xsl:stylesheet>
Here is what i get out of this.
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="InstallFolder">
<Component Id="cmpAEC985F4FAA50E51011E84E93A32F283" Guid="{3574FFF9-F47D-4A3F-A975-64D76546068A}">
<File Id="fil9C01928D57F128482FD2A78A209FBF95" KeyPath="yes" Source="$(var.SourcePath)\AppSettings.config"/>
</Component>
<Component Id="cmp10AE81284551BB54849628AE519965C7" Guid="{CF245728-B329-454E-A305-BE33FC818572}">
<File Id="fil3F1ECB9AAE6412D0FDF9577B44764BA9" KeyPath="yes" Source="$(var.SourcePath)\CsvHelper.dll"/>
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="FileComponents">
<ComponentRef Id="cmpAEC985F4FAA50E51011E84E93A32F283"/>
<ComponentRef Id="cmp10AE81284551BB54849628AE519965C7"/>
<ComponentRef Id="cmp596F6F97E366DDB8E0770EC1550C6CB5"/>
</ComponentGroup>
</Fragment>
</Wix>
But I aslo want to remove the ComponentRef referencing to the already removed Component. Can anyone tell me how to do this?
PS: I tried to create an variable containing the ID of the Component (since I dont know this, and cannot put this into my XSLT file). But then I could not get to the CompenentGroup and remove the ComponentRef.