MohawkMEDIC / everest

The Everest Framework is designed to ease the creation, formatting, and transmission of HL7v3 and CDA structures with remote systems.
Apache License 2.0
38 stars 22 forks source link

Section.NullFlavor = NullFlavor.NoInformation issue #12

Closed MikeCheel closed 6 years ago

MikeCheel commented 6 years ago

I have Section objects that I am setting the Code, Title, and Text properties on.

When I have entries for the section, I create the Entry objects and add them to the Section object. At document creation time everything looks good and validates.

When I do NOT have entries I am setting section.NullFlavor = NullFlavor.NoInformation; and all I get at document creation time for the section is: <section xsi:nil="true" nullFlavor="NI" />

The problems are:

When I validate I get

Attribute 'http://www.w3.org/2001/XMLSchema-instance,nil' must not appear on element 'section', because the {nillable} property of 'section' is false.

The other properties (like Code, Title and Text) are not rendered to the xml.

What am I doing wrong?

justin-fyfe commented 6 years ago

Hi,

Typically when NullFlavor is set, sub-elements should not be rendered (as the parent is null). I think you can suppress the generation of XSI:NIL by using the SettingsType.SuppressXsiNil setting when you create the formatter:

formatter.Settings = formatter.Settings | SettingsType.SuppressXsiNil;
MikeCheel commented 6 years ago

I figured it out. I needed to set the Entry to NullFalvor.NoInformation (and the other stuff doesn't get nil'd) and not the Section. Thanks for your assistance!