I have created this xsl for dynamically create .WXS output.But i am facing one issue like as per the below xsl it creates component group for each folder.I don't want to create component group for each folder and i need to have only one component group and add all the components into this group.
I have one component gruop "HelpFiles_Group" as mentioned in the below output and it generates from heat.exe.I have added "extjs","css" folders manually within the same "HelpFiles_Group" group but i am expecting this should be part of XSL..
使用下面的xsl时,它会为“extjs”,“css”文件夹创建不同的组件组。任何想法我们如何将所有组件添加到同一个组件组中?以下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: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>
输出.WXS预期。
<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>
根据新XSL输出
<?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" />
答案 0 :(得分:0)
我认为你遇到的问题是你在 xsl:for-each
中创建 wix:ComponentGroup 元素 <xsl:for-each select="wix:Fragment/wix:DirectoryRef/wix:Directory">
<wix:Fragment>
<wix:ComponentGroup Id="{@Name}">
对于每个 wix:DirectoryRef ,您实际上只需要一个 wix:ComponentGroup ,这意味着您可能需要两个嵌套的 xsl:for-each 语句,一个用于 wix:DirectoryRef ,另一个嵌套在 wix:Directory
中尝试这样的事情
<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>