简体   繁体   中英

wix heat remove namespace using xsl file

here is my pre-build script:

"%WIX%\bin\heat.exe" dir "$(SolutionDir)Export\Release\SkyCam\Config" -t   "$(SolutionDir)IQStudioInstaller\SimulatorIgnore.xsl" -dr Simulator -srd -cg SimulatorComponentGroup -var var.SimulatorSourcePath -ag -sreg -out "$(SolutionDir)IQStudioInstaller\IQStudioSimulatorDir.wxs"

here is my *.xsl file:

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


  <xsl:output omit-xml-declaration="yes" indent="yes" encoding="utf-8"/>
  <xsl:strip-space  elements="*"/>
  <!-- identity transform -->
  <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="@*"/>
      <RemoveFolder Id="{@Id}" On="uninstall" />
      <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
      <xsl:apply-templates select="node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

the problem i have is the xlmns attribute added which is added to my and :

xmlns="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"

why this being added and how can i remove it?


<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="Simulator" />
    </Fragment>
    <Fragment>
        <ComponentGroup Id="SimulatorComponentGroup">
            <Component Id="cmpCAB8CD4B3E3F5DE9BD27E4BE2C6D4ED5" Directory="Simulator" Guid="*">
                <RemoveFolder Id="cmpCAB8CD4B3E3F5DE9BD27E4BE2C6D4ED5" On="uninstall" **xmlns="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"** />
                <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" xmlns="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
                <File Id="fil763F3807501181AEBB3384E197DA1B60" KeyPath="yes" Source="$(var.SimulatorSourcePath)\aeStatGridWeights.txt" />
            </Component>
            <Component Id="cmp9FA0A11B61A218ED2C433E82749C7264" Directory="Simulator" Guid="*">
                <RemoveFolder Id="cmp9FA0A11B61A218ED2C433E82749C7264" On="uninstall" **xmlns="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"** />
                <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" xmlns="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
                <File Id="fil52CCB4416F79DAB20B21723321A693FD" KeyPath="yes" Source="$(var.SimulatorSourcePath)\afStatGridWeights.txt" />
            </Component>

update:

I edit my *.xsl file like Tim suggested and it fixed one of the problems

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

  <xsl:output omit-xml-declaration="yes" indent="yes" encoding="utf-8"/>
  <xsl:strip-space  elements="*"/>
  <!-- identity transform -->
  <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="@*"/>
      <RemoveFolder Id="{@Id}" On="uninstall" />
      <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
      <xsl:apply-templates select="node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

output now is:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="Simulator" />
    </Fragment>
    <Fragment>
        <ComponentGroup Id="SimulatorComponentGroup">
            <Component Id="cmpCAB8CD4B3E3F5DE9BD27E4BE2C6D4ED5" Directory="Simulator" Guid="*">
                <wix:RemoveFolder Id="cmpCAB8CD4B3E3F5DE9BD27E4BE2C6D4ED5" On="uninstall" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
                <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
                <File Id="fil763F3807501181AEBB3384E197DA1B60" KeyPath="yes" Source="$(var.SimulatorSourcePath)\aeStatGridWeights.txt" />
            </Component>
            <Component Id="cmp9FA0A11B61A218ED2C433E82749C7264" Directory="Simulator" Guid="*">
                <wix:RemoveFolder Id="cmp9FA0A11B61A218ED2C433E82749C7264" On="uninstall" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
                <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
                <File Id="fil52CCB4416F79DAB20B21723321A693FD" KeyPath="yes" Source="$(var.SimulatorSourcePath)\afStatGridWeights.txt" />
            </Component>

so the xmlns="" is gone!
however it didn't solve the xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"

The problem is with these lines

  <RemoveFolder Id="{@Id}" On="uninstall" />
  <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />

You are outputting elements in NO namespace, but for your Wix file, they need to go in the " http://schemas.microsoft.com/wix/2006/wi " namespace.

You can easily fix this by specifying the relevant namespace prefix for the elements

  <wix:RemoveFolder Id="{@Id}" On="uninstall" />
  <wix:RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />

Alternatively, you can add the wix namespace as the default namespace to the XSLT too

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

That way elements with no namespace prefixes will actually be part of the default namespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM