如何在XML中定义名称空间? [英] How to define a namespace in XML?
问题描述
我将Eclipse用于J2EE编程.在HTML代码中,我们可以使用xmlns属性使用JSF(或任何其他)名称空间.使用xmlns属性指定名称空间后,说xmlns:f="..."
,然后在键入<f:
时自动获得f
名称空间下的标签.
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.
我如何定义它?
推荐答案
如果只是名称空间,您要做的就是选择一个保证唯一的URL并将其用作您的名称空间.常见的约定是在您拥有的域下使用网址,例如 http://www.idiotguy.com/my-super-xml-namespace
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.
名称空间本身并没有说明文档结构.为此,您需要编写DTD或XSD并将其链接到文档.
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.
这篇关于如何在XML中定义名称空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!