Write a wix extension
它处理该XML命名空间中的元素。下面的示例扩展将导致命名空间中的任何元素
http://www.example.com
被忽视:
将以下代码保存在
mywixext.cs
:
using System.Xml.Schema;
using Microsoft.Tools.WindowsInstallerXml;
using System.Xml;
[assembly: AssemblyDefaultWixExtension(
typeof(mywixext.IgnoreNamespaceWixExtension))]
namespace mywixext
{
public class IgnoreNamespaceWixExtension : WixExtension
{
public override CompilerExtension CompilerExtension
{
get
{
return new IgnoreNamespaceCompilerExtension();
}
}
}
public class IgnoreNamespaceCompilerExtension : CompilerExtension
{
public override XmlSchema Schema
{
get
{
return new XmlSchema()
{
TargetNamespace = "http://www.example.com"
};
}
}
public override void ParseElement(
SourceLineNumberCollection sourceLineNumbers,
XmlElement parentElement, XmlElement element,
params string[] contextValues)
{
// do nothing
}
}
}
现在编译成
mywixext.dll
这样地:
"c:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe" /t:library ^
/r:"c:\program files\windows installer xml v3\bin\wix.dll" ^
mywixext.cs
如果现在使用选项编译wix源
-ext mywixext.dll
(或在votive中执行等效操作)然后
网址:http://www.example.com
将忽略命名空间。
编辑
:当我说任何元素都将被忽略时,我是不精确的。WIX XML架构不允许您直接将自己的子元素添加到
WIX
元素。大多数其他元素都允许这样做。查找文本
<xs:any namespace="##other" processContents="lax">
在里面
c:\program files\windows installer xml v3\doc\wix.xsd
找到可扩展性点。