元素名称的大小写约定? [英] Case conventions on element names?

查看:102
本文介绍了元素名称的大小写约定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在XML元素大小写方面是否有任何 formal 建议?

Are there any formal recommendations on element casing in XML?

我知道XHTML使用小写的元素名称(与HTML规范地相反)使用大写字母,但不区分大小写。)

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

但是我说的是通用内容的XML。

But I'm talking about XML for generic content.

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



camelCase:



camelCase:

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



PascalCase:



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.

推荐答案

大多数源自W3C的XML标准都倾向于使用

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

在将XML视为平台中立文档的格式(W3C标准试图鼓励这种格式)与XAML等语言之间存在哲学上的区别XML作为平台特定对象图的序列化。

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.

如果您不是将XML用作平台无关的文档格式,而是将其用作应用程序特定的序列化,那么您可能并省去了一些麻烦,并且XML名称与平台特定名称之间具有1:1的对应关系。但是,为此目的,几乎所有其他对象图格式都比XML更好。

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.

如果您愿意,那么您可能希望与XHTML,XSLT,SVG,XProc, RelaxNG和其他。

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

这篇关于元素名称的大小写约定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆