简体   繁体   English

XML元素值中的命名空间?

[英]Namespace in XML element value?

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>

The namespace dp0 is actually used in the element value, does that mean anything at all? 名称空间dp0实际上是在元素值中使用的,那有什么意思吗?

At the XML level, no, a namespace prefix has no meaning within content -- namespaces and namespace prefixes are purely markup-level constructs. 在XML级别上,不,名称空间前缀在内容中没有任何意义-名称空间和名称空间前缀纯粹是标记级的构造。

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. 此外,任何在内容中使用名称空间前缀的应用程序都必须注意只关心前缀所绑定的名称空间,而不是前缀本身。

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. 最后,由于名称空间前缀( dp0 ,here)除了通过与名称空间值( http://www.onvif.org/ver10/network/wsdl )的关联dp0 ,都是微不足道的,因此名称空间前缀的数字0后缀为也微不足道。 Typically, it's just a counter appended programmatically to ensure that the namespace prefix is unique. 通常,它只是以编程方式附加的计数器,以确保名称空间前缀是唯一的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM