Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
724 views
in Technique[技术] by (71.8m points)

xml - Case conventions on element names?

Are there any formal recommendations on element casing in XML?

I know XHTML uses lowercase element names (as opposed to HTML which canonically uses uppercase but is case-insensitive.)

But I'm talking about XML for generic content.

lowercase:

<customer> 
   <accountnumber>619</accountnumber>
   <name>Shelby Lake</name>
</customer>

camelCase:

<customer> 
   <accountNumber>619</accountNumber>
   <name>Shelby Lake</name>
</customer>

PascalCase:

<Customer> 
   <AccountNumber>619</AccountNumber>
   <Name>Shelby Lake</Name>
</Customer>

UPPERCASE:

<CUSTOMER> 
   <ACCOUNTNUMBER>619</ACCOUNTNUMBER>
   <NAME>Shelby Lake</NAME>
</CUSTOMER>

Note: I'm looking for cited guidelines rather than opinions. But the opinion with the most up-votes can be considered a guideline.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Most XML standards originating from the W3C tend to use lower case with hyphens.

There is a philosophical distinction between seeing XML as a format for platform neutral documents, which W3C standards try to encourage, and languages such as XAML which see XML as a serialisation of a platform specific object graph.

If you're not using XML as a platform neutral document format, but as an application specific serialisation, then you might as well save yourself some bother and have a 1:1 correspondence between the XML names and the platform specific names. But almost any other object graph format is better than XML for that purpose.

If you are, then you might want to fit in with XHTML, XSLT, SVG, XProc, RelaxNG and the rest.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...