Namespace in XML element value?

半腔热情 提交于 2019-12-02 08:09:23

问题


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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/38745861/namespace-in-xml-element-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!