【问题标题】:Ant xmltask <attr> creates an empty "xmlns" attribute valueAnt xmltask <attr> 创建一个空的“xmlns”属性值
【发布时间】:2017-03-30 21:36:28
【问题描述】:

我有一个如下的 XML 文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CustomObject>
</CustomObjects>

我通过以下方式应用 XMLTask attr:

<attr path="/CustomObject" attr="xmlns" value="test"/>

我希望 XML 文件现在包含属性 xmlns,其值为“test”

实际输出如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CustomObject xmlns="">
</CustomObjects>

以前有人遇到过这个问题吗?或有任何迹象表明可能是什么问题?

【问题讨论】:

    标签: xml ant xmltask


    【解决方案1】:

    看起来 xmltask 无法创建名称为 xmlns 的属性。这似乎是一个已知错误:#8 attr name="xmlns" does not work on Mac

    在 XML 中,xmlns 是保留的属性名称。它指的是默认命名空间。有关默认命名空间的更多信息,请参阅 XML 1.0 W3C 建议中的命名空间中的 Namespace Defaulting

    作为替代解决方案,请考虑使用XSLT to add a namespace to the root element

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多