XSL为每个文件夹和Subfolder创建新的ComponentGroup。我需要在单个组件组中添加所有组件

时间:2013-07-12 06:56:02

标签: xml xslt xslt-1.0 xslt-2.0

使用下面的xsl时,它会为文件夹和子文件夹创建不同的组件组。任何想法我们如何将所有组件添加到同一个组件组中?以下XSL需要进行哪些更改?

<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: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>

使用多个组件组输出[我只需要一个组件组]

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <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="_2090.css" Directory="Simulation_Help" Guid="{D813EAB4-95EC-4704-85CA-9F21355FA8F9}">
        <File Id="_2090.css" KeyPath="yes" Source="$(var.OnLineHelp.SorceDir)\2090.css" />
      </Component>
      <Component Id="_2236.htm" Directory="Simulation_Help" Guid="{B1CCAF7F-E1BE-4E90-A297-BA18ADF646AD}">
        <File Id="_2236.htm" KeyPath="yes" Source="$(var.OnLineHelp.SorceDir)\2236.htm" />
      </Component>
    </wix:ComponentGroup>

  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:guid="clitype:System.Guid?partialname=mscorlib">
    <wix:ComponentGroup Id="extjs">
      <wix:Component Id="extjs" Directory="extjs" Guid="PUT-GUID-HERE">
        <wix:RemoveFolder Id="extjs" On="uninstall" />
        <wix:RegistryValue Root="HKCU" Key="SOFTWARE\IOM\NgSSimulation" Type="string" Value="NextGen" KeyPath="yes" />
      </wix:Component>
    </wix:ComponentGroup>
  </wix:Fragment>
  <wix:Fragment xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:guid="clitype:System.Guid?partialname=mscorlib">
    <wix:ComponentGroup Id="images">
      <wix:Component Id="images_1" Directory="images_1" Guid="PUT-GUID-HERE">
        <wix:RemoveFolder Id="images" On="uninstall" />
        <wix:RegistryValue Root="HKCU" Key="SOFTWARE\IOM\NgSSimulation" Type="string" Value="NextGen" KeyPath="yes" />
      </wix:Component>
    </wix:ComponentGroup>
  </wix:Fragment>
</Wix>

0 个答案:

没有答案