Today Wing found a problem when trying to write back document changes using BEA ALDSP. The error message stated that the heritage of the changes was ambiguous. Viewing the query plan for the relevant data source, we found a warning stating that the type of the result did not match the type of the document. Further investigation revealed that if we changed the return type of the data source function from 'Activity' to 'Activity*', then everything worked -- except that now the document was wrapped in one of BEA's famous generated 'array' types. It turns out that the expression that was computing the return result implied a maxOccurs of "unbounded", e.g. for $activity in ns0:getActivity(). We knew, however, that this function always returned no more than one result. Thus, the problem was solved by changing the expression to let $activity := ns0:getActivity()[1]. Interesting that the compiler was correctly identifying that the expression actually returned Activity* but didn't complain when the function was declared as returning Activity.