Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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
Xml wix使用xsl文件删除名称空间_Xml_Xslt_Wix_Wix3.6_Wix3.7 - Fatal编程技术网

Xml wix使用xsl文件删除名称空间

Xml wix使用xsl文件删除名称空间,xml,xslt,wix,wix3.6,wix3.7,Xml,Xslt,Wix,Wix3.6,Wix3.7,这是我的预构建脚本: "%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)IQSt

这是我的预构建脚本:

"%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"
这是我的*.xsl文件:

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

我遇到的问题是添加了xlmns属性,该属性被添加到我的和中:

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

为什么要添加此项以及如何删除它



更新:

我按照Tim的建议编辑了*.xsl文件,解决了其中一个问题

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

现在的输出是:


所以
xmlns=”“
就不见了

但是,它没有解决
xmlns:wix=”问题http://schemas.microsoft.com/wix/2006/wi“

问题在于这些行

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

您正在输出没有命名空间的元素,但对于Wix文件,它们需要进入“”命名空间

通过为元素指定相关的名称空间前缀,您可以轻松地解决这个问题

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

或者,您也可以将wix名称空间作为默认名称空间添加到XSLT中

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


这样,没有名称空间前缀的元素实际上将成为默认名称空间的一部分。

您的问题不清楚。您想从输出中完全删除wix名称空间,还是只删除冗余(无害)前缀及其绑定?我不确定您能做多少。虽然它看起来很奇怪,但从语义上讲,结果是正确的,而且应该由Wix解析。
  <wix:RemoveFolder Id="{@Id}" On="uninstall" />
  <wix:RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
<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">