Reputation: 292345
The way I understand it, an XML namespace name can be any valid URI; however, it seems that they're always URIs with the http://
scheme. Is this a rule, a guideline, just a convention? Can I use something like urn:foo:bar
instead?
Here's my specific usage scenario: I want to define an XML namespace for a library of mine, to make its usage easier in XAML. I could use the URL of the GitHub repository, but if the project's home ever changes, the namespace name will become an obsolete URL (and if I change it, it will break existing code). So I'm thinking of using an URI like urn:myname:myproject
instead.
Is this a acceptable practice? If not, what would be a good way to handle the fact that the project's home might change, making the URL obsolete?
Upvotes: 1
Views: 66
Reputation: 89285
"Can a XML namespace name be something other than an HTTP URI?"
Sure it can. The official documentation of 'Namespaces in XML' mention about criteria of a namespace identifier, and in the same place mention about URN and URL as possible candidates for the task :
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.
So, as long as the URI you're going to use carries the recommended characteristics, I would say it is acceptable practice to use it.
Upvotes: 1