Re: Element names guidelines

Hi Frans,

> At the risk of starting a flamefest, I wonder: What is the best
> naming conventions for elements and attributes? A crucial question
> in modeling XML formats.

In my opinion, the best naming scheme will differ from markup language
to markup language, and in the end it doesn't matter which naming
scheme you actually use, as long as you use it consistently.

For example, don't mix capitalisation, don't use ., - or _ as
separators as some names but not in others, don't use different
separators within the same name, apply abbreviations consistently
wherever a word is used, and so on.

Sometimes aiming for consistency means that you have to adopt the
naming conventions adopted by a markup language that you reuse, or the
database/application from which your markup language is generated.

Another consideration is how the markup language fits in with the
naming schemes used by applications that are used to process the
markup language. For example, if you want a one-to-one mapping between
element names and variables or properties in your favourite
programming language then you probably want to avoid using . or - as
separators in the element names.

One thing that rubs me up the wrong way is multi-part names where the
first part of the name is the same as the name of the parent element,
for example if you have:

  <Person>
    <PersonName>
      <PersonNameFirst>...</PersonNameFirst>
      ...
    </PersonName>
    ...
  </Person>

since this leads to XPaths that look like:

  Person/PersonName/PersonNameFirst

rather than:

  Person/Name/First

Similarly, it's a bad idea to use the name of the markup language
within the name of an element, since then you tend to get repetition
of namespace prefixes within the element names.

I'd also almost always argue against using drastic abbreviations in
any persisted document, since I like to try to help out historians
from the future who might read them.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Thursday, 18 November 2004 16:06:55 UTC