Generate XML with xsi:nil="true" when null value

I am creating my first XML file based on a provided XSD spec. The specification is widely used by other organizations, so I’m confident it is correct.

In examples they provide, a null field value should be reprensented by:

My file is generating the following instead:
ns1:DiplomaCount />

I have confirmed at the database the field value for DiplomaCount is null, and that I do not map a blank string or anything else to it. Am I missing an option that I need to set that will send xsi:nil=“true”?

The XML validation tool provided by the vendor confirms that they will reject the file if the null fields do not contain xsi:nil=“true” for null values in nullable elements.

We are running DI 11.7.3.1
I would appreciate feed back on this version, but would also like to know if things are different in future versions. So anything you know is appreciated.
Thanks


hellmanj (BOB member since 2007-09-14)

I’ll keep updating as I figure out more.

Using the “Replace Null or Blank With” option for the fileformat in the dataflow does not generate the results I need. This produces:
ns1:DiplomaCountxsi:nil=“true”</ns1:DiplomaCount>

My XML ref book from years ago states:

xsi:nil
“The xsi_:nil attribute indicates that a certain element does not have a value or that the value is unknown.”…“It is not relevant whether an empty-element tag or start-tag/end-tag pair is used to represent the nil element.”…“In order for this document to be valid, the element declaration for the name element must explicitly specify that nil values are allowed by setting the nillable attribute to true. For example:
<xs:element name=“last_name” type=“xs:string” nillable=“true”/>”


hellmanj (BOB member since 2007-09-14)

I’m going to file a ticket as well with BOE. Using the “replace Nulls/Blank” option was promising enough that I tried it and then did a find/replace on the final file to shift the data inside the < /> brackets.

This does not work because not all fields that have a null/blank are allowed to use the special syntax of xsi:nil=“true”. For it to be valid, your FSD has to declare it using the following syntax.
<xsd:element name=“DiplomaCount” nillable=“true”>

I looked at the attributes stored with the XML file format and it does not appear the DI version I am on is loading the Nillable value into an attribute. If it was, that would open up additional possibilities.


hellmanj (BOB member since 2007-09-14)

Interesting. :+1:


Werner Daehn :de: (BOB member since 2004-12-17)

Filing a ticket resulted in the statement that this would need to be an enhancement request. These xsi:nil=“true” option is not available in our version 11.7 nor did it sound to be available in any of the more recent versions of DI.

I solved this problem by using perl script and lookup file. The file has pairs of words seperated by a comma. One pair per line.
(e.g. ,<\elementA>)
The script goes through the list of 120 pairs and does a global find replace writing the results to a new file.

My Perl is a bit rusty, but my sys admin mentioned he had something and saved me some time. Not sure if I can share the code.


hellmanj (BOB member since 2007-09-14)

What if I consume a web service which uses the NILABLE elements in the request. How do I pass them xsi:nil=true instead of the element which is nested?

And will I be able to see the SOAP request envelope that gets generated?


cpmohanraj :australia: (BOB member since 2002-09-23)