问题描述
我最近偶然发现了这个:
I recently stumbled across this:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>
<a:MessageID>uuid:21859bf9-6193-4c8a-ad50-d082e6d296ab</a:MessageID>
<a:ReplyTo>
<a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>
</s:Header>
<s:Body>
<Probe xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery">
<d:Types xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dp0="http://www.onvif.org/ver10/network/wsdl">dp0:NetworkVideoTransmitter</d:Types>
</Probe>
</s:Body>
</s:Envelope>
让我困惑的一件事是这条线:-
One thing that perplexes me is the line:-
<d:Types xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dp0="http://www.onvif.org/ver10/network/wsdl">dp0:NetworkVideoTransmitter</d:Types>
命名空间dp0
实际上是用在元素值中,这有什么意义吗?
The namespace dp0
is actually used in the element value, does that mean anything at all?
推荐答案
在 XML 级别,不,名称空间前缀在内容中没有意义——名称空间和名称空间前缀纯粹是标记级别的构造.
At the XML level, no, a namespace prefix has no meaning within content -- namespaces and namespace prefixes are purely markup-level constructs.
此外,任何在内容中使用命名空间前缀的应用程序都必须注意只关心前缀绑定的命名空间,而不是前缀本身.
Furthermore, any application that uses namespace prefixes in the content will have to take care to only care about the namespace to which the prefix is bound, not the prefix itself.
最后,因为命名空间前缀(dp0
,这里)是无关紧要的,除了通过它与命名空间值的关联(http://www.onvif.org/ver10/network/wsdl
),命名空间前缀的数字 0
后缀也无关紧要.通常,它只是一个以编程方式附加的计数器,以确保命名空间前缀是唯一的.
Finally, since the namespace prefix (dp0
, here) is insignificant other than via through its association with a namespace value (http://www.onvif.org/ver10/network/wsdl
), the numeric 0
suffix of the namespace prefix is also insignificant. Typically, it's just a counter appended programmatically to ensure that the namespace prefix is unique.
这篇关于XML 元素值中的命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!