Loading ...
Sorry, an error occurred while loading the content.

xsi:nil and nillable [was RE: [FormsPlayer] Alert]

Expand Messages
  • Mark Birbeck
    Bjørn, ... If you say in your schema that an item is a date or an integer (for example) then it *must* be a date or an integer. An empty string is obviously
    Message 1 of 1 , Jun 11, 2003
    • 0 Attachment
      Bjørn,

      > These fields are empty on initiating. The binding is for input control.
      > Is it a problem if the fields are empty in the initiating XML instance?

      If you say in your schema that an item is a date or an integer (for example)
      then it *must* be a date or an integer. An empty string is obviously not a
      date or an integer. One way round this is to redefine your schema to allow
      an empty value, but this is a lot of work for each data type that you want,
      and anyway, this may not fit with the logic of your schema. For example, the
      integer 'how many years have you lived at your previous address', may be
      allowed to be empty if the person has lived at their current address for
      more than three years.

      A better way then, would be to set the nillable attribute in your schema,
      and then set the xsi:nil attribute to "true" on the instance data:

      <xforms:instance>
      <instanceData>
      <YearsAtAddress>
      <current>4</current>
      <previous xsi:nil="true" />
      </YearsAtAddress>
      </instanceData>
      </xforms:instance>

      If your schema says that 'previous' is an integer then this would mean that
      it also cannot be empty, but in this example we can see that the person has
      been at their current address more than 3 years, so we set 'previous' to
      nil. (Note that this is not the same as using the model item properties such
      as required.)

      You could turn this value on and off using a <bind>:

      <xforms:bind nodeset="previous/@xsi:nil"
      calculate="/YearsAtAddress/current > 3" />

      or whatever.

      See:

      <http://www.w3.org/TR/xmlschema-0/#Nils>

      for more information.

      Regards,

      Mark


      Mark Birbeck
      Managing Director
      x-port.net Ltd.
      4 Pear Tree Court
      London
      EC1R 0DS

      E: Mark.Birbeck@...
      W: www.x-port.net
      T: +44 (20) 7689 9232
    Your message has been successfully submitted and would be delivered to recipients shortly.