How to define a namespace in XML?

你。 提交于 2020-02-16 04:03:43

问题


I use Eclipse for J2EE programming. In the HTML code, we can use the JSF (or any other) namespaces using the xmlns attribute. Once you specify a namespace using the xmlns attribute, say xmlns:f="...", and when you type <f: you automatically get the tags under the f namespace.

I want to define my own namespace with a list of tags and attributes for every tag.

How do I define it?


回答1:


If it's just the namespace, all you need to do is pick a URL that is guaranteed to be unique and use it as your namespace. A common convention is to use a URL under a domain you own, e.g. http://www.idiotguy.com/my-super-xml-namespace.

The namespace by itself doesn't say anything about the document structure though; for that, you need to write a DTD or XSD and link your document to it.



来源:https://stackoverflow.com/questions/7661381/how-to-define-a-namespace-in-xml

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