我正在为WiX的Heat实用程序创建一个转换,该转换需要禁止在正在收获的树下禁止匹配特定名称(.PayloadData)的文件夹的收获。
我可以轻松获取它来隐藏Directory和Component元素,但是ComponentRef元素非常棘手。
该文件夹称为.PayloadData,它成功取消了Directory和Component元素:
<xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:Directory[@Name='.PayloadData']/*" />
我为ComponentRef元素尝试了类似的方法,但它与所有内容都匹配。
<xsl:template match="wix:ComponentRef[//wix:Directory[@Name='.PayloadData']/wix:Component[@Id=@Id]]">
我认为@Id在xpath表达式中可能是模棱两可的,但我不知道如何告诉ComponentRef的Id属性试图匹配Component的Id属性。
以下是输入内容:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)\..\Common\Common.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirFD22039A64AC1D31F568C1632B5AF8A3" Name=".PayloadData">
<Component Id="cmp846A29F6413B27E8777DD68E6026E461" Guid="*">
<File Id="fil9227EFCE377E7FEBB63A4BD121F278AE" KeyPath="yes" Source="$(var.SampleDataDir)\.PayloadData\SampleData.xml" />
</Component>
</Directory>
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\01-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\02-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\ProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\SPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\UpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp846A29F6413B27E8777DD68E6026E461" />
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>
这是所需的输出
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)\..\Common\Common.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\01-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\02-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\ProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\SPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)\AlternativePBS\UpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>
它需要删除:
答案 0 :(得分:0)
感谢您的帮助。我现在有了答案。钥匙就是钥匙(双关语意味):
<xsl:key name="ComponentsToSuppress" match="wix:Component[ancestor::wix:Directory[@Name='.PayloadData']]" use="@Id" />
<xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:ComponentRef[key('ComponentsToSuppress', @Id)]" />
这使我可以抑制出现在名为“ .PayloadData”的目录下的项目的Component和ComponentRef,无论它出现在什么位置(或出现频率)。