XML delimiters tell the difference between xsi: nil = "true" and missing elements?

Are XML parsers / deserializers generally capable of distinguishing between nillable elements explicitly specified by null and optional elements that are not specified ?

Suppose we have the following complex type:

<complexType name="NiceType">
  <sequence>
    <element name="niceElem" nillable="true" type="int" minOccurs="0" />
  </sequence>
</complexType>

The element is explicitly set to zero (example 1):

<niceType>
  <niceElem xsi:nil="true"/> 
</niceType>

Element omitted (example 2):

<niceType>
</niceType>

Can analyzes in general, such as JAX-B or .NET implementations, such as the WCF XML module, determine the difference between Example 1 and Example 2 above? In other words, are you compatible with both NULL representations, as in the example, in order to report different shades of NULL?

+5
source share
1 answer

XML- (, XmlReader, XmlDocument, XDocument) xsi:nil - /.

XmlSerializer xsi:nil: , node; WCF XmlSerializer, DataContract XmlSerializerFormatterAttribute.

DataContractSerializer : , ( ) - . , xsi:nil DataContractSerializer, , DataContractSerializer /.

spec , , JavaScript null undefined - null (xsi:nil) , undefined () - ; - , ( ).

, . - , API REST/SOAP, ( InfoPath, ); null = undefined. xmlns .

: (, xsd:int), # <Name>Specified - , . xsi:nil omittance (nil, , null, , ). XmlSerializer.

+2

All Articles