Type of issue
Current Behavior
The way XmlEncoder encodes a "null" Variant value is incorrect.
A Variant value is encoded as an xs:complexType with the following XML schema:
<xs:complexType name="Variant">
<xs:sequence>
<xs:element name="Value" minOccurs="0" nillable="true">
<xs:complexType>
<xs:sequence>
<xs:any minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
Which means the expected output for something like:
var context = new ServiceMessageContext();
string actualXmlValue;
using (IEncoder xmlEncoder = new XmlEncoder(context))
{
Variant value = Variant.Null;
xmlEncoder.PushNamespace(Namespaces.OpcUaXsd);
xmlEncoder.WriteVariant("Test", value);
xmlEncoder.PopNamespace();
actualXmlValue = xmlEncoder.CloseAndReturnText();
}
would be some variation of:
<Test xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<uax:Value xsi:nil="true" />
</Test>
yet the implementation of XmlEncoder yields this:
<Test xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<Value>
<Null />
</Value>
</Test>
Ignore the namespaces and prefixes - the problem is the element named "Null" for which a reference does not exist in either Part 6 nor the the schema defined by http://opcfoundation.org/UA/2008/02/Types.xsd.
I believe another valid encoding based on the schema includes:
<Test>
<Value></Value>
</Test>
Type of issue
Current Behavior
The way
XmlEncoderencodes a "null" Variant value is incorrect.A Variant value is encoded as an xs:complexType with the following XML schema:
Which means the expected output for something like:
would be some variation of:
yet the implementation of
XmlEncoderyields this:Ignore the namespaces and prefixes - the problem is the element named "Null" for which a reference does not exist in either Part 6 nor the the schema defined by http://opcfoundation.org/UA/2008/02/Types.xsd.
I believe another valid encoding based on the schema includes: