【问题标题】:Using XSLT for modifying .wxs from heat使用 XSLT 从热量中修改 .wxs
【发布时间】:2013-01-04 09:08:52
【问题描述】:

我想使用 xslt 来编辑 wix 中 heat 生成的 .wxs 文件

这是 components_en_us.wxs

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
        <Fragment>
            <DirectoryRef Id="CLASSES">
                <Directory Id="dirAB609E465A12655D740B32B2BA26C468" Name="alfresco">
                <Directory Id="dir68A1A3CC25353B021B1D7D979B520AF0" Name="extension">
                    <Component Id="cmp0FAE663628DD6BAE53501BB26264259B" Guid="1CBE6568-96E5-4844-BF02-99AF0DE1719D">
                        <File Id="fil867FDB2D2761B5912BA54F92F5E928D1" KeyPath="yes" Source="SourceDir\alfresco\extension\web-client-config-custom.xml" />
                    </Component>
                </Directory>
                </Directory>
            </DirectoryRef>
    </Fragment>
</Wix>

但问题是我有其他 .wxs 文件(对于其他语言,components_xx_yy.wxs)并且组件/文件 ID 是相同的。如果我用这种方法编译会报错

error LGHT0091 : Duplicate symbol 'Component:cmp0FAE663628DD6BAE53501BB26264259B' found. 
This typically me ans that an Id is duplicated. Check to make sure all your identifiers 
of a given type (File, Component, Feature) are unique.

我google了一下,发现可以使用xslt来改变components_en_us.wxs中的Component/File id

所以,我期待类似的东西

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="CLASSES">
            <Directory Id="dirAB609E465A12655D740B32B2BA26C468" Name="alfresco">
            <Directory Id="dir68A1A3CC25353B021B1D7D979B520AF0" Name="extension">
                <Component Id="en_US_cmp0FAE663628DD6BAE53501BB26264259B" Guid="1CBE6568-96E5-4844-BF02-99AF0DE1719D">
                    <File Id="fil867FDB2D2761B5912BA54F92F5E928D1" KeyPath="yes" Source="SourceDir\alfresco\extension\web-client-config-custom.xml" />
                </Component>
            </Directory>
            </Directory>
        </DirectoryRef>
    </Fragment>
</Wix>

现在,我从另一个问题获得了这个 xslt,但我不知道如何按照我的意愿实现它。

<?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:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

所以,如果我的理解有误,请纠正我,也请帮助我处理 .xslt

提前致谢

编辑:这种方式是最佳做法,还是我应该做其他事情来解决这个重复错误。

【问题讨论】:

    标签: xml xslt wix windows-installer heat


    【解决方案1】:

    我能在这两个 XML 列表之间找到的唯一变化是在组件 ID 前添加了“en_US_”。这是全部吗?如果是这样,请尝试将此模板添加到您当前的 XSLT 文件中:

    <xsl:template match="wix:Component/@Id">
       <xsl:attribute name="{name()}">
         <xsl:value-of select="concat('en_US_', .)" />
       </xsl:attribute>
    </xsl:template>
    

    【讨论】:

    • 感谢您的快速响应,我已尝试将您的代码添加到我的 XSLT 文件中,但我的 .WXS 文件没有任何变化。
    • 啊,我没有意识到您的 XML 使用了命名空间。我修改了我的代码的第一行。请立即尝试。
    • 确实没有。第三次是魅力? :)
    猜你喜欢
    • 2015-10-12
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    相关资源
    最近更新 更多