设置我自己的 XML 命名空间? [英] Set up my own XML namespace?

查看:29
本文介绍了设置我自己的 XML 命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置自己的 XML 命名空间?

How can I setup my own XML namespace?

推荐答案

只需在根标签(或任何需要命名空间的地方)定义命名空间.示例:

Just define a namespace in the root tag (or wherever you need the namespace). Example:

<root xmlns:ns="some_identifier">

ns 并且标识符可以(几乎)是任何东西.请参阅此引用:

ns and the identifier can be (nearly) anything. See this quote:

命名空间名称指向什么?

What Do Namespace Names Point At?

关于这一切的一个令人困惑的事情是命名空间名称是 URL;很容易假设,因为它们是 Web 地址,所以它们一定是某物的地址.他们不是;这些是 URL,但命名空间草案并不关心它们指向什么(如果有的话).想想 XML.com 程序员寻找书名的例子;无需命名空间名称指向任何内容即可正常工作.

One of the confusing things about all this is that namespace names are URLs; it's easy to assume that since they're Web addresses, they must be the address of something. They're not; these are URLs, but the namespace draft doesn't care what (if anything) they point at. Think about the example of the XML.com programmer looking for book titles; that works fine without the namespace name pointing at anything.

W3C 决定使用 URL 作为命名空间名称的原因是它们包含域名(例如 www.xml.com),这些域名在 Internet 上全球通用.

The reason that the W3C decided to use URLs as namespace names is that they contain domain names (e.g. www.xml.com), which work globally across the Internet.

维基百科文章也非常有用.

我希望你知道你需要命名空间来区分具有相同名称的标签.

I hope you know that you need namespaces just for distinguishing tags with the same name.

这篇关于设置我自己的 XML 命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆