Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt XSL总是创建新的ComponentGroup,而不是将组件添加到Heat.exe中使用的同一组件组中_Xslt_Wix_Xslt 2.0 - Fatal编程技术网

Xslt XSL总是创建新的ComponentGroup,而不是将组件添加到Heat.exe中使用的同一组件组中

Xslt XSL总是创建新的ComponentGroup,而不是将组件添加到Heat.exe中使用的同一组件组中,xslt,wix,xslt-2.0,Xslt,Wix,Xslt 2.0,在使用下面的xsl时,它正在为“extjs”、“css”文件夹创建不同的组件组。您知道如何将所有组件添加到同一个组件组中吗?以下XSL中需要进行哪些更改 我的XSL, 不 应为Ouput.WXS <xsl:stylesheet version="2.0" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-

在使用下面的xsl时,它正在为“extjs”、“css”文件夹创建不同的组件组。您知道如何将所有组件添加到同一个组件组中吗?以下XSL中需要进行哪些更改

我的XSL,
应为Ouput.WXS

<xsl:stylesheet version="2.0"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="wix">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="wix:Wix">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      <xsl:for-each select="wix:Fragment/wix:DirectoryRef/wix:Directory">
        <wix:Fragment>
          <wix:ComponentGroup Id="{@Name}">
            <xsl:if test="count(descendant::wix:Component) = 0">
              <wix:Component Id="{@Id}" Directory="{@Id}" Guid="">
                <wix:RemoveFolder Id="{@Name}" On="uninstall" />
                <!--<wix:RegistryValue Root="HKCU" Key="SOFTWARE\IOM\NgSSimulation" Type="string" Value="NextGen" KeyPath="yes" />-->
              </wix:Component>
            </xsl:if>
          </wix:ComponentGroup>
        </wix:Fragment>
      </xsl:for-each>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="wix:Component">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()" />
      <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\NgSSimulation" Type="string" Value="SimCentral" KeyPath="yes" xmlns="http://schemas.microsoft.com/wix/2006/wi"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="wix:File">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:attribute name="KeyPath">
        <xsl:text>no</xsl:text>
      </xsl:attribute>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>


根据新的XSL输出

<Fragment>
    <DirectoryRef Id="Simulation_Help">
      <Directory Id="extjs" Name="extjs" />
      <Directory Id="images_1" Name="images" />
      <Directory Id="uilocale" Name="uilocale" />
    </DirectoryRef>
  </Fragment>
  <Fragment>
    <ComponentGroup Id="HelpFiles_Group">

      <Component Id="extjs" Guid="{8FB704ED-5A08-42DF-A593-8F04AD8EAB64}" Directory="extjs">
        <RemoveFolder Id="SimSciHelp_extjs" On ="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\SimCentral" Type="string" Value="SimCentral" KeyPath="yes" />
      </Component>

      <Component Id="css" Guid="{A5066974-3279-4C45-85EA-F3A7F55343C4}" Directory="css">
        <RemoveFolder Id="css" On ="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\SimCentral" Type="string" Value="SimCentral" KeyPath="yes" />
      </Component>

      <Component Id="default" Guid="{BF114032-02E5-49B1-A8FD-F927843A5E7A}" Directory="default">
        <RemoveFolder Id="default" On ="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\SimCentral" Type="string" Value="SimCentral" KeyPath="yes" />
      </Component>

      <Component Id="button" Guid="{42BE8034-622B-4C76-8FA1-78DDD151037C}" Directory="button">
        <RemoveFolder Id="button" On ="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\IOM\SimCentral" Type="string" Value="SimCentral" KeyPath="yes" />
      </Component>



它不应该创建单独的组件组,而是所有组件id都应该在第一个组件组中。我认为您的问题是,您正在为每个xsl:for-each创建wix:ComponentGroup元素

        <?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="Simulation_Help">
      <wix:Component Id="extjs" Directory="extjs" Guid="">
        <wix:RemoveFolder Id="extjs" On="uninstall" />
      </wix:Component>
      <wix:Component Id="images_1" Directory="images_1" Guid="">
        <wix:RemoveFolder Id="images" On="uninstall" />
      </wix:Component>
      <wix:Component Id="uilocale" Directory="uilocale" Guid="">
        <wix:RemoveFolder Id="uilocale" On="uninstall" />
      </wix:Component>
    </wix:ComponentGroup>
  </wix:Fragment>
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="uilocale" />
  </wix:Fragment>
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="images_1" />
  </wix:Fragment>
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="tree" />
  </wix:Fragment>
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <wix:ComponentGroup Id="toolbar" />

实际上,每个wix:DirectoryRef只需要一个wix:ComponentGroup,这意味着每个语句可能需要两个嵌套的xsl:xsl,一个用于wix:DirectoryRef,一个嵌套在wix:DirectoryRef

试试这样的

  <xsl:for-each select="wix:Fragment/wix:DirectoryRef/wix:Directory">
    <wix:Fragment>
      <wix:ComponentGroup Id="{@Name}">


您有两个与wix:Component匹配的模板,这是不允许的,因为XSLT无法确定使用哪一个模板。您的XSLT示例确实正确吗?您好,我已经用XSLT更新了这个问题。请对此提供帮助。现在,您有三个模板匹配wix:Component元素!也许您希望在不同的上下文中使用它们,但目前XSLT无法决定使用哪一个,因为它们都匹配相同的元素。也许您可以编辑您的问题以显示实际的.wxs文件,以及预期的输出。或者,您可以解释一下,您希望何时使用每个模板。谢谢我已经更新了问题。我尝试添加Hi,我正在创建一个.wxs,如上所述,但我需要仅为文件夹和子文件夹添加RemoveFolder。我该怎么做?我认为需要更改上面代码中的一些现有模板。xslt中需要做什么更改才能在文件夹和子文件夹中包含RemoveFolder?not file LEVEL更新了该问题…正在努力为上述情况创建xsl。请使用代码片段对此进行帮助。我认为,如果您修改了您的问题,以显示一个小而完整的.wxs文件示例,以及您期望的输出示例,这将有所帮助。非常感谢。我附上了XSLT示例。因为我必须使用RemoveFolder键为每个文件夹创建组件id。我仍然有点困惑。如果您展示了输入XML的一个小而完整的示例,以及您所期望的输出XML的一个示例,这将非常有帮助。非常感谢。
  <xsl:for-each select="wix:Fragment/wix:DirectoryRef/wix:Directory">
    <wix:Fragment>
      <wix:ComponentGroup Id="{@Name}">
<xsl:template match="wix:Wix">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
    <xsl:for-each select="wix:Fragment/wix:DirectoryRef">
      <wix:Fragment>
        <wix:ComponentGroup Id="{@Id}">
          <xsl:for-each select="wix:Directory">
             <xsl:if test="count(descendant::wix:Component) = 0">
               <wix:Component Id="{@Id}" Directory="{@Id}" Guid="">
                 <wix:RemoveFolder Id="{@Name}" On="uninstall" />
                 <!--<wix:RegistryValue Root="HKCU" Key="SOFTWARE\IOM\NgSSimulation" Type="string" Value="NextGen" KeyPath="yes" />-->
               </wix:Component>
             </xsl:if>
           </xsl:for-each>
        </wix:ComponentGroup>
      </wix:Fragment>
    </xsl:for-each>
  </xsl:copy>
</xsl:template>