When I started playing with XML, I was an early adopter. It was interesting, intrigant. Now, everybody knows what XML is and other needs arise, such as “how the heck do I write those tags?”.
The purpose of this document is to propose a standard for writing elements and attributes in a coherent way.
I googled for XML coding convention, XML coding style, XML writing convention, XML writing style… I got basically nothing interesting.
So I went to the industry leaders and tried to discover a trend, a de facto standard. Sun with Java and Eclipse have a convention; Apache, OASIS and W3C have another one. Sun provides Java SE, Java EE with numerous XML files.
Apache provides Ant, Maven, Jelly and many projects using XML. W3C provides many core specifications (XML, XML Schema…), while OASIS provides application standards (ebXML, OpenDocument, DocBook…).
Oracle exports data from database in another way.
Therefore, I enforce & recommend the following rule, based on OASIS:
- Applies to both elements and attributes.
- Applies, when possible to attributes’ values.
- First word is all lowercase.
- Following words are glued to the previous, in lowercase except for the initial.
- Acronyms are all uppercase.
- Use of intelligible words & abbreviations.
It is very similar to the naming convention used for a Java method (function).
|cacheTTL||Cache-TTL, cache-TTL, cacheTtl|
This is a list of preferres keywords for use in XML tags (elements, attributes and value of attributes).
|description||Description of an item||desc, descr|
|javaName||Name in Java.|
|className||Name of a class.|
Source of Inspiration
This standard is used by / derived from:
|SVG||Scalable Vector Graphics||1.1||W3C||http://www.w3.org/TR/SVG11|
|RSS||Really Simple Syndication||2.0||Harvard LawSchool||http://blogs.law.harvard.edu/tech/rss|
|Torque XML database schema DTD||3.2||Apache||http://db.apache.org/torque/dtd|