< a_element/>和有什么区别?并且< a_element xsi:nil ="true"/&gt ;? [英] What's the difference between <a_element /> and <a_element xsi:nil="true" />?

查看:107
本文介绍了< a_element/>和有什么区别?并且< a_element xsi:nil ="true"/&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道XML/XSD上的这些标签之间是否有区别?

do you know if there's a difference between these tags on XML/XSD?

<a_element /> and <a_element xsi:nil="true"/>

例如:

<SpreadCurve>
      <Index>3M</Index>
      <IndexNumber>4587</IndexNumber>
      <BusinessArea xsi:nil="true" />
</SpreadCurve>

and

<SpreadCurve>
      <Index>3M</Index>
      <IndexNumber>4587</IndexNumber>
      <BusinessArea />
</SpreadCurve>

这些等效吗?

如果我有XSD元素:

<xsd:element name="BusinessArea" type="xsd:string"/>

这意味着默认情况下为xsi:nil ="false".这意味着它将不接受该元素的空值.

this means that it is by default xsi:nil="false". And this means it will not accept a null value for this element.

我的疑问是,它会接受吗?

My doubt is, will it accept this one?

<BusinessArea />

这对XSD到底意味着什么?

What does this really mean to the XSD?

最好的问候

推荐答案

您将获得此信息,因为您的XSD BusinessArea应定义为nillable ="true".像这样:

You get this as your XSD BusinessArea should be defined as nillable="true". Something like:

<xsd:element name="BusinessArea" nillable="true">
.....
</xsd:element> 

这意味着BusinessArea元素可以具有空值,即为空.

What this mean is that BusinessArea element can have null value i.e. empty.

如果XML中的元素不包含任何值,则它必须具有属性xsi:nil ="true":

And if element in XML doesn't contain any value then it must have attribute xsi:nil="true":

<BusinessArea xsi:nil="true" />

这应该是无效的:

<BusinessArea />

您显示的两个示例不应该等效.

Two examples you showed should not be equivalent.

检查一下以了解xsi:nil和nillable:

Check this out for understanding xsi:nil and nillable:

http://www.zvon.org/xxl/XMLSchemaTutorial/Output/ser_over_st0.html

http://www.w3.org/TR/xmlschema-0/#尼尔斯

这篇关于&lt; a_element/&gt;和有什么区别?并且&lt; a_element xsi:nil ="true"/&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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