Thursday, January 8, 2009

xsi:nil

From the HL7 lists:
Xsi:nil is what allows you to exclude mandatory class attributes and associations when you declare a parent association as “null”. For example, assume you have a patient role with a 1..1 non-mandatory association to playing person which in turn has mandatory attributes name and date of birth.


In schema, you’ll end up with a 1..1 “nillable” element called PlayingPerson which in turn has 1..1 non-nillable elements for name and birthTime. If for some reason the person information is unknown, the instance would send the playingPerson element with an attribute of xsi:nil=”true”, nullFlavor=”UNK”, and no child elements. Normally, that would be a violation of the schema because both name and birthTime have a minimum cardinality of 1. However because xsi:nil is set to true, the schema validator essentially “skips” validating the contents of the nil element, which is what you want.
- Lloyd Mckenzie writes.


All non-mandatory associations should therefore be declared as nillable. (We don’t do the same thing with datatypes because none of the datatype properties have a minimum cardinality of 1 in the schema.)

No comments: