使用
this online tester可以很容易地看到以下问题
我有一个web.config,看起来像:
<?xml version="1.0"?> <configuration> <nlog/> </configuration>
并且变换看起来像:
<?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <xdt:Import assembly="AppHarbor.TransformTester" namespace="AppHarbor.TransformTester.Transforms"/> <nlog xdt:Transform="Replace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <targets async="true"> <target name="LogMill" xsi:type="FallbackGroup" returnToFirstOnSuccess="true"> <target xsi:type="LogMillMessageBus"/> <target xsi:type="File" fileName="..\LogMill-FailSafe.log" layout="${TextErrorLayout}"/> </target> </targets> </nlog> </configuration>
但输出不是我所期望的,它将xsi命名空间声明向下移动到使用它的元素,这导致nlog无法解析配置,并且错误参数p4不支持FallbackGroupTarget
<?xml version="1.0"?> <configuration> <nlog> <targets async="true"> <target name="LogMill" p4:type="FallbackGroup" returnToFirstOnSuccess="true" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance"> <target p4:type="LogMillMessageBus" /><target p4:type="File" fileName="..\LogMill-FailSafe.log" layout="${TextErrorLayout}" /> </target> </targets> </nlog> </configuration>
是否有可以应用的转换选项或语法来阻止它移动命名空间声明?我在the documentation找不到任何东西
解决方法
将您的xmlns:xsi =“http://www.w3.org/2001/XMLSchema-instance”声明移动到最顶层的元素,它应该没问题
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。