开发者

What does xmlns="" exactly mean

Given the following (piece of) a soap call;

<m1:NextCommencementDateInput xmlns:m1="http://foo.bar.com/Types">
    <aDate xmlns="">2010-06-02</aDate>
</m1:NextCommencementDateInput>

Apperantly this is the same as (when validating against the xsd using XMLSpy)

<m1:NextCommencementDateInput xmlns:m1="http://foo.bar.com/Types">
    <aDate>2010-06-02</aDate>
</m1:NextCommencementDateInput>

So what does xmlns="" do exactly ?

Edit: To elaborate why I'm asking this is because I'm calling a third party and they are now stating that we should remove xmlns="开发者_运维技巧" from our requests. I however think they are the same and they should change their side.


xmlns="" clears definition of default namespace (aka empty prefix). After this declaration all elements without prefix are considered to have null namespace.

So the difference is:

  • First example (with xmlns="") clears empty prefix so aDate element has null namespace.

  • Second example doesn't clear it. Namespace of aDate element depends on namespace declaration in containing scope. If there is active xmlns="some:namespace" declaration, aDate will have this namespace. Otherwise it will have null namespace.

Additionally some XML parsers complain on xmlns="" if there is no active xmlns="some:namespace" declaration to clear...


According to the XML Namespace specification (§6.2), they are completely identical other than for the extra attribute itself (which your implementation may or may not hide from you).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜