XML元素有标准命名约定吗? [英] Is there a standard naming convention for XML elements?

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

问题描述

XML文档有任何标准,事实上或其他方面吗?例如,哪种是​​最好的写标签的方式?

Is there any standard, de facto or otherwise, for XML documents? For example which is the "best" way to write a tag?

<MyTag />
<myTag />
<mytag />
<my-tag />
<my_tag />

同样,如果我有一个更好的属性的枚举值

Likewise if I have an enumerated value for an attribute which is better

<myTag attribute="value one"/>
<myTag attribute="ValueOne"/>
<myTag attribute="value-one"/>


推荐答案

我怀疑最常见的值是camelCased - ie

I suspect the most common values would be camelCased - i.e.

<myTag someAttribute="someValue"/>

特别是,如果与代码生成器混合序列化xml到对象),因为很多语言允许枚举带空格(要求两者之间的映射)。

In particular, the spaces cause a few glitches if mixed with code-generators (i.e. to [de]serialize xml to objects), since not many languages allow enums with spaces (demanding a mapping between the two).

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

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