Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML tag and attributes naming conventions 2

Status
Not open for further replies.

alebu

Programmer
Sep 7, 2002
46
0
0
Hi,
Currently I am involved in writing code standarts for my company and there is serious question about XML tags and attributes naming conventions.
There is three types of them:
1) Camel case - new word starts from Capitalized character.
Apache uses such approach.
2) Use minus (-) sign. For example, ii is used in XSLT.
3) To use underscore (_) sign - I found examples with underscore on and I now that some people use it.
In general, any of mentioned approches is OK, but I wonder if there some official recomendations for it.
What is your opinion?
 
>but I wonder if there some official recomendations for it.
There is not one "offically", not even "semi-officially".

In his book <Effective XML> Elliotte R Harold has a good concise section "Item 6 Name Elements with Camel Case". In case you're not in a position to get hold of it and for general reading members, here are some cases supplement to what you've noted. (I've edited them for brievety in cases of word for word.)

[1] XSLT uses all lower case with hyphens separating words.
[2] The WXSL uses camel case with an initial lowercase letter.
[3] DocBoook uses lower case exclusively and never separates the words.
[4] MathML uses lower case exclusively, does not separate the words and furthermore often abbreviates the words.
[5] SOAP 1.2 uses camel case with initial capitals for element names and camel case with an initial lowercase letter for attributes.
[6] XHTML uses lower case exclusively with fairly short, abbreviated names.

Here are some succinct opinions.

[7] The one style you tend not to see is exclusively upper case. (Reason: difficult to read.)
[8] XML vocabularies do tend to be verbose. Most valcabularies prefer to spell out the complete names of things rather than abbreviating. A few applications, such as DocBook and XHTML use at least some abbreviations.
[8bis] but, in general it's considered good form to spell out all words completely. (Note: if it is written as bad form to use abbreviation, I would very much disagree.)
[9] (Word separation) The hyphen is eschewed because many data binding APIs can't easily map names containing hyphens to class names.
[9bis] (my summary) Underscore, Camel case are the prime candidates for word separation...
[10] "In the programming sections of Usenet, case conventions are second only to indentation as a source of pointless erudition and time-wasting flameage."
[11] "All I [Harold] can really recommend is that you pick one convention and stick with it."

With the above, one may make a more informed decision to stick with. But, I may have little faith in sticking rigidly to any convention without consideration of a good judgement of life-span of what one scripts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top