WiX WSLT 转换以从 .wsx 文件中删除属性

WiX WSLT transform to remove an attribute from a .wsx file

另一个变换新手问题:我正在尝试提出一个变换,它将从加热的 .wxs 文件中删除一个属性。

Heat 正在生成 Class 属性 'RelativePath="yes",这会在编译器中引发错误。在我们的例子中,该属性不是必需的。只是将其更改为 "no" 并不能消除错误。我想要做的是 运行 一个删除属性的转换。

当前输出文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="SystemFolder">
            <Component Id="todgub7.dll" Guid="{4DEBD59A-D93A-43CC-AD8A-2198E1C308F7}" Permanent="yes">
                <File Id="todgub7.dll" KeyPath="yes" Source="$(var.OC2.WinSys32)\todgub7.dll">
                    <Class Id="{359AA0C1-DDF8-49DB-83FF-6184706A9106}" Context="InprocServer32" Description="ComponentOneUnboundDataSource" RelativePath="yes" ThreadingModel="apartment">
                        <ProgId Id="ComponentOneUnboundDataSource" Description="ComponentOne OLE DB Data Source for Unbound Mode" />
                    </Class>
                </File>
                <RegistryValue Root="HKCR" Key="CLSID\{359AA0C1-DDF8-49db-83FF-6184706A9106}\RefCount" Value="1" Type="string" Action="write" />
            </Component>
        </DirectoryRef>
    </Fragment>
</Wix>

我希望得到:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="SystemFolder">
            <Component Id="todgub7.dll" Guid="{4DEBD59A-D93A-43CC-AD8A-2198E1C308F7}" Permanent="yes">
                <File Id="todgub7.dll" KeyPath="yes" Source="$(var.OC2.WinSys32)\todgub7.dll">
                    <Class Id="{359AA0C1-DDF8-49DB-83FF-6184706A9106}" Context="InprocServer32" Description="ComponentOneUnboundDataSource" ThreadingModel="apartment">
                        <ProgId Id="ComponentOneUnboundDataSource" Description="ComponentOne OLE DB Data Source for Unbound Mode" />
                    </Class>
                </File>
                <RegistryValue Root="HKCR" Key="CLSID\{359AA0C1-DDF8-49db-83FF-6184706A9106}\RefCount" Value="1" Type="string" Action="write" />
            </Component>
        </DirectoryRef>
    </Fragment>
</Wix>

这是拼图的补充部分我已经运行进行转换以将 addtribute Pemanent="yes" 添加到组件。

这是我目前正在 运行 进行的转换(由本论坛慷慨提供):

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="wix:Component">
    <xsl:copy>
      <xsl:apply-templates select="@*" />
      <xsl:attribute name="Permanent">
        <xsl:text>yes</xsl:text>
      </xsl:attribute>
      <xsl:apply-templates select="node()" />
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

将此模板添加到您的样式表中:

 <xsl:template match="@RelativePath"></xsl:template>

由于它更具体,它将优先于复制未命名属性的其他模板 RelativePath