[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

CamelCase names for XML elements vs. property names for Java beans

  • From: "Tolkin, Steve" <Steve.Tolkin@f...>
  • To: "'xml-dev@i...'" <xml-dev@i...>
  • Date: Tue, 18 Jan 2000 12:45:47 -0500

java bean property naming convention
In XML both object and their properties can be represented by
elements, with a object being a non-leaf element and a property a leaf
element.  (See quote from BizTalk guidelines below.)  But this
distinction is not a strong one, e.g. the leaf element <name> can
later be changed to a non-leaf element with children <firstName> and
<lastName>.  (This is unlike the relational model of databases, where
the distinction between tables and columns is a strong one.)

Q1. Should leaf elements use a different naming convention than
non-leaf elements?
I think these should use the same convention, to make it easy to
"migrate" between whether an element is a leaf or non-leaf element.

Q2. Should elements use lowerCamelCase or UpperCamelCase?
I at first adopted UpperCamelCase for two reasons:
* It looks much more natural to ordinary end users, who might see the
XML tags e.g. in the IE tree control.  For example "PurchaseOrder"
sems much more like the natural language "Puchase Order" than does
* XML elements are more likely to be represented as classes than as
properties (because elements themselves can have XML attributes).

But this is in conflict with the naming convention for Java beans: 
the name of a bean property must start with a lowercase letter.  
(Actually this is not a requirement, but if it is not followed the java
programmer must explictly write a bunch of code instead of having the
getFoo and setFoo accessors "for free".)  It seems desirable, but
highly unlikely, hat Java beans change to frst try to find a property
named Foo i.e. starting with an uppercase letter.

Summary: there are at least three reasonable naming conventions
and here are their pros and cons.
1. All Elements UpperCamelCase: 
Pro: Elements names are consistent so it is easy to "migrate".
Pro: Has "user-friendly" tag names.
Con: Violates BizTalk guidelines.
Con: Hard to use with Java beans.

2. All Elements lowerCamelCase: 
Pro: Elements names are consistent so it is easy to "migrate".
Pro: Easy to use with Java beans
Con: Violates BizTalk guidelines.
Con: Does not have "user-friendly" tag names.

3. Non-leaf elements are UpperCamelCase and 
leaf elements are lowerCamelCase:
Pro: Follows BizTalk guidelines.
Even: Leaf elements easy to use with Java beans, but not non-leaf elements.
Even: Leaf elements have "user-friendly" names, but not non-leaf elements.
Con: Element names are not consistent so it is hard to "migrate".

What approach are people using?  What other factors matter here?

Steven Tolkin 

P.S.  I know we could use lowercase_with_underscore-or-dash names, 
so please do not suggest this.

In the BizTalk Framework Document Design Guide
    Names and Cases: Names should use the style called
"CamelCase." If an element reflects a thing (an object, a class or a
table name), use UpperCamelCase; if it is a property, a reference,
etc., use lowerCamelCase.
    Expressing Data: All simple data (trees, columns, rows, objects,
properties, etc.) should be expressed as elements and subelements, not

An excerpt from beans_101.pdf downloaded 2000-01-14 from 
8.2 Overview of Design Patterns
... For example the use of getFoo and setFoo methods to
retrieve and set the values of a "foo" property. 
[The first character after the accessor prefix of is, get, or set
is forced to lowercase.  This only appears in the examples.
It is a subtle point that should have been stated explicitly.  

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ or CD-ROM/ISBN 981-02-3594-1
Please note: New list subscriptions now closed in preparation for transfer to OASIS.


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.