我使用XMLFILE元件安装过程中添加元素的XML文件:如何设置在维克斯使用XMLFILE当xmlns属性3
<util:XmlFile Id="SetOracleDialectProperty"
Action="createElement"
ElementPath="//hibernate-configuration/session-factory"
Name="property"
Sequence="9"
File="[INSTALLLOCATION]Config\hibernate.config"
Value="NHibernate.Dialect.Oracle10gDialect"/>
空文件,我这样写的外观:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
</session-factory>
</hibernate-configuration>
运行我结束了此安装程序后:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property xmlns="">NHibernate.Dialect.Oracle10gDialect</property>
</session-factory>
</hibernate-configuration>
的问题是,空xmlns属性正在重写在文件的根节点中指定的xmlns,因此nhibernate无法正确识别属性元素。
如何设置值以匹配根节点或删除xmlns属性?
我花了一些时间寻找答案,最接近的我发现是“做你会做的MSXML”这不会帮助我,因为它没有说如何在WiX中做到这一点(例如XmlFile使用什么属性)。
编辑 要稍微解释罗布的回答,在一个地方,我可以用漂亮的格式:
- 您由XMLConfig的元素设置节点=“文件”添加文档片段。
- 您必须显式设置名称空间,否则您将再次获得默认名称空间。
- 此外,虽然您要添加一个“文档”,但如果指定了多个元素,它似乎不起作用。你会得到一个神秘且彻底无用的“安装向导过早结束”运行时错误。
所以我固定的代码如下所示:
<util:XmlConfig Id="MsSqlDialect"
Action="create"
ElementPath="//hibernate-configuration/session-factory"
File="[INSTALLLOCATION]Config\hibernate.config"
Node="document">
<![CDATA[
<property xmlns="urn:nhibernate-configuration-2.2" name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
]]>
</util:XmlConfig>