xml i:nil="true" 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/463597/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does i:nil="true" mean?
提问by dtc
I have an xml and it has nodes with i:nil="true" in it. What does that mean?
我有一个 xml,其中包含 i:nil="true" 的节点。这意味着什么?
For example:
例如:
<FirstName i:nil="true" />
Does that mean something different than:
这是否意味着不同于:
<FirstName />
If so, what is the difference?
如果是这样,有什么区别?
回答by Ray Lu
This means FirstName is null
这意味着名字为空
<FirstName i:nil="true" />
This means FirstName = ""
这意味着名字 = ""
<FirstName />
Assumption made on FirstName is of string type.
对 FirstName 的假设是字符串类型。
回答by Torsten Marek
Maybe i:nilactually means xsi:nil, this means that the FirstNameelement is empty, i.e. does not have anycontent -- not even "". It refers to the nillableproperty in XML Schema.
也许i:nil实际上意味着xsi:nil,这意味着该FirstName元素是空的,即没有任何内容——甚至没有""。它指的是nillableXML Schema 中的属性。
回答by Lasse V. Karlsen
nil is an attribute, defined in the inamespace. For this FirstName node, the attribute has the value true.
nil 是一个属性,定义在i命名空间中。对于此 FirstName 节点,该属性的值为true。
It's similar to this, just with different names and values:
它与此类似,只是名称和值不同:
<form name="test">...
Here, formis the name of the node, similar to FirstNamefrom your code, and nameis an attribute with a value of "test", similar to your attribute nilwith a value of "true".
这里,form是节点的名称,类似于FirstName您的代码,并且name是一个值为“test”的属性,类似于您nil的值为“true”的属性。
What this means depends on the application reading the xml document.
这意味着什么取决于读取 xml 文档的应用程序。
If I were to venture a guess, I'd say that this looks like part of a xml document defining some kind of schema, and that the FirstName field can have a NULL or nilvalue, meaning empty, or unknown.
如果让我大胆猜测,我会说这看起来像是定义某种架构的 xml 文档的一部分,并且 FirstName 字段可以具有 NULL 或nil值,表示空或未知。

