XML 名称空间名称可以是 HTTP URI 以外的名称吗?

Can a XML namespace name be something other than an HTTP URI?

按照我的理解,XML 命名空间名称可以是任何有效的 URI;然而,它们似乎是 always URIs with the http:// scheme。这是规则、指南还是惯例?我可以改用 urn:foo:bar 之类的东西吗?

这是我的具体使用场景:我想为我的一个库定义一个XML命名空间,以便于在XAML中使用它。我可以使用 GitHub 存储库的 URL,但是如果项目的主页发生变化,命名空间名称将变为过时的 URL(如果我更改它,它将破坏现有代码).所以我正在考虑使用 urn:myname:myproject 之类的 URI。

这种做法可以接受吗?如果不是,那么什么是处理项目主页可能发生变化的好方法,使 URL 过时?

"Can a XML namespace name be something other than an HTTP URI?"

当然可以。 'Namespaces in XML' 的官方文档提到了命名空间标识符的标准,并在同一个地方提到了 URN 和 URL 作为任务的可能候选者:

The namespace name, to serve its intended purpose, should have the characteristics of uniqueness and persistence. It is not a goal that it be directly usable for retrieval of a schema (if any exists). An example of a syntax that is designed with these goals in mind is that for Uniform Resource Names [RFC2141]. However, it should be noted that ordinary URLs can be managed in such a way as to achieve these same goals.

因此,只要您要使用的 URI 具有推荐的特征,我认为使用它是可以接受的做法。