Next: , Up: Record Polymorphism   [Contents]

2.5.1 Checking Compatibility

When considering compatibility, we introduce a potential point of failure during header creation; but the record header functions are primitive operations that, in order to simplify the system, should ideally guarantee success. R:make-record-header#3 will silently upgrade the slot count as necessary to ensure record compatibility; it is up to the caller to perform necessary validations and decide whether to fail.

function: xs:boolean R:is-compatible (Sub as element( R:Record ), Super as element( R:Record ))


Determine whether record Sub is compatible with a supertype Supet.


<function name="R:is-compatible"  as="xs:boolean">
  <param name="Sub"  as="element( R:Record )" />
  <param name="Super"  as="element( R:Record )" />

  <sequence select="R:slot-count( $Sub ) >= R:slot-count( $Super )" />