如何选择新的XML语言的命名空间名称?

发布于 2024-10-03 02:48:21 字数 363 浏览 0 评论 0原文

我创建了一种基于 XML 的(特定于领域的)语言,我希望它能被广泛使用。为了“实现”它,我使用了 xsd 文件。

到目前为止,我一直使用像这样的 url 作为 xml 语言命名空间:

http://languagemainsite.org/lang/1.0/

现在,我不确定这是选择命名空间的最佳方式,从长远来看:

  1. 也许命名空间中的版本号有点过大?它也已经在“version”属性中定义了,但我认为每个版本都有不同的 url 会很好吗?
  2. 为此使用 url 总是好的吗?
  3. ????

关于为基于 xml 的语言命名名称空间有什么建议吗?

I've created a (domain-specific) language based on XML that I hope will be widely used. To "implement" it I'm using an xsd file.

Until now I've used an url like this as the xml-language namespace :

http://languagemainsite.org/lang/1.0/

Now, I'm not sure it's the best way to choose the namespace, for long term:

  1. Maybe the version number in the namespace is overkill? It's already defined in the "version" attribute too, but I thought it would be nice to have different url per version?
  2. Is it always good to use an url for this?
  3. ????

Any advice about naming namespaces for xml-based language?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

呢古 2024-10-10 02:48:21

如果命名空间 http://languagemainsite.org/lang/1.0/ 中的 foo 元素在语义上与中的 foo 元素是不同的概念命名空间 http://languagemainsite.org/lang/1.1/,命名空间应该不同。如果不是,如果 Lang-1.1 foo 只是 Lang-1.0 foo 可能具有一些额外的功能,那么它们应该位于相同的命名空间中。

例如,考虑 XHTML 1.0、XHTML 1.1 和 XHTML5 中的

元素。在所有版本的 XHTML 中,它在语义上都是相同的东西(一个段落),因此它们都可以存在于 http://www.w3.org/1999/xhtml 命名空间中,即使它们具有不同的内容不同语言版本的功能。

在命名空间中包含版本号会使向后兼容性变得非常困难。支持该语言的两个版本的应用程序必须切换命名空间以处理相同的命名元素,并且支持版本 1 的应用程序实际上根本无法读取版本 2 文档。

因此,仅将版本化命名空间用于故意完全降低向后兼容性的新“主要版本”更新。否则,根元素上的 version 属性通常是一个更好的主意。

是的,您应该使用 URL,以避免与其他人的名称空间发生冲突。在您使用的 URL 上添加一些描述性信息是礼貌的做法。

If the foo element in the namespace http://languagemainsite.org/lang/1.0/ is semantically a different concept to a foo element in the namespace http://languagemainsite.org/lang/1.1/, the namespaces should be different. If they're not—if a Lang-1.1 foo is just a Lang-1.0 foo maybe with a few extra features—they should be in the same namespace.

Consider, for example, the <p> element in XHTML 1.0, XHTML 1.1 and XHTML5. It is semantically the same thing (a paragraph) in all versions of XHTML, so they can all live in the http://www.w3.org/1999/xhtml namespace, even though they have different capabilities in the different language versions.

Including a version number in the namespace makes backwards-compatibility very difficult. Applications supporting two versions of the language would have to switch namespaces to cope with the same named elements, and a version-1-supporting application can't practically read a version-2 document at all.

So only use versioned namespaces for new ‘major version’ updates that deliberately completely drop backwards compatibility. Otherwise, a version attribute on the root element is generally a better idea.

And yes, you should use a URL, in order to avoid clashing with others' namespaces. It's polite to put some descriptive information up at the URL you use.

誰認得朕 2024-10-10 02:48:21

我认为这看起来是一个合理的命名空间 URI。

至于版本号;我认为这是个好主意。 xml 声明中的版本号不能使用(它必须是 1.0,或者可能是 1.1,并且指示 xml 解析本身如何工作,而不是所包含数据或语言的版本。这是一种常用的做法,我认为没有太大价值不包括它在那里。

I think that looks like a reasonable namespace URI.

As to version number; I think that is a good idea. Version number in xml declaration can NOT be used (it MUST be 1.0, or possibly 1.1, and dictates how xml parsing itself works and not version of contained data or language. This is a commonly used practice, and I don't see much value in not including it in there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文