Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good or common naming conventions for XML namespace URIs

I'm looking for some ideas for good naming conventions for xsd target namespaces.

Basically I just need to make a definite decision on how to name the target namespace of my xsd so I try to get it right the first time. Changing it later would require changes to another system which is not in my control.

Do you have any experience from past XML schema creations on what is a good and working solution? I've tried to find information online, but most examples just use very generic target namespaces like "http://exampleSchema" and similar. I'm actually trying to find some real life examples.

like image 617
Anne Schuessler Avatar asked Jan 07 '11 07:01

Anne Schuessler


People also ask

What is namespace URI in XML?

A namespace name is a uniform resource identifier (URI). Typically, the URI chosen for the namespace of a given XML vocabulary describes a resource under the control of the author or organization defining the vocabulary, such as a URL for the author's Web server.

What is an XML namespace A set of names?

What Is an XML Namespace? An XML namespace is a collection of names that can be used as element or attribute names in an XML document. The namespace qualifies element names uniquely on the Web in order to avoid conflicts between elements with the same name.

Which character is used while defining a namespace prefix?

The prefix xmlns is used only to declare namespace bindings and is by definition bound to the namespace name http://www.w3.org/2000/xmlns/ . It MUST NOT be declared or undeclared. Other prefixes MUST NOT be bound to this namespace name.

What is the default namespace in XML?

When you use multiple namespaces in an XML document, you can define one namespace as the default namespace to create a cleaner looking document. The default namespace is declared in the root element and applies to all unqualified elements in the document. Default namespaces apply to elements only, not to attributes.


1 Answers

W3C's own practices for long-lived URI selection are a pretty good baseline for XML namespace URIs. See Cool URIs don't change for some suggestions, with the exception that a namespace URI need not be retrievable and so some of those guidelines may not apply.

  • Use a prefix that is unambiguously tied to the specification owner such as the URI of your Web server. If the schema will be available online, it's a nice touch if it can be found at its naming URI. The use of HTTP URLs is not required, though it is common practice.
  • Include a rough date close after (year and month is good) so that if, in the future, you reorganize your namespace, the vintage of the name (and therefore its internal organization) is unambiguous. Note that this is the date the URI was first allocated, not the date of the current version.
  • Add a name to identify the subject matter of this particular schema, so you can tell it from other related schemas. This name should be immutable, even if the marketing name of the subject has to change. Maybe someone else who holds a trademark on it surprised you, maybe the sales department wants to try a new spin, but code shouldn't break.
  • Finally, if subsequent versions of the same conceptual schema are not mutually compatible, add a unique versioning component to indicate the compatibility break. If the versioning is handled within the scope of the vocabulary (such as by a version attribute), on the other hand, leave this out.

XSLT uses the following:

http://www.w3.org/1999/XSL/Transform

This fits the pattern above. Owner identifier, date, and name; and no versioning component because versioning is handled within the XSLT vocabulary.

In a pinch, you can even get away with

mailto:[email protected]?Subject=2008+XML+Basketweaving+specification

which fits the pattern as well but suggests a point of contact instead of an information repository.

like image 132
Jeffrey Hantin Avatar answered Oct 15 '22 14:10

Jeffrey Hantin