変換スクリプト変換スクリプトは、イベントを XML ファイルに書き込む前に、その内容や構造を変更するために使用します。場合によっては、受信者のニーズに合わせてイベントを変換する必要があります。 たとえば、条件のチェックに使用しても最終的な出力には含めない属性を削除することができます。または、標準イベント (「create」、「change」、または 「delete」) を特定イベント (「orderedQuantityIncreased」 など) に名前変更することができます。必要に応じて、イベントのデータにもとづくまったく新しい XML 構造を作成することもできます。 変換スクリプトでは、datrgevent ライブラリの関数を使用してイベントのデータを読み取ります。 変換スクリプトを作成するには、次の手順を実行します。
テンプレート 変換スクリプトごとに、次のコードをテンプレートとして使用します。 function extern long transform.event(ref long io.event)
| IMPORTANT: do not change the interface (function name, parameter,
| and return value)
{
DLLUSAGE
Desc This function transforms a trigger event.
Input io.event: event
Output return value: 0 (OK) or < 0 (an error value)
io.event: transformed event
Precondition: i.event contains an event that is formatted according
to library datrgevent and must be read using that
library.
Postcondition: o.event is filled and contains an XML structure that
either is or is not according to library datrgevent.
ENDDLLUSAGE
| < Add implementation here > |
return(0) | OK
}
例 変換スクリプトの例として、次のコードを参照してください。 | The following transformation changes the standard events 'create', | 'change' and 'delete to a specific event 'takeAction'. Additionally, | it removes the 'old values', and in case of 'delete' it moves the | contents to the (new) values. #define ERROR_IF(condition, return.value) ^ if condition then ^ return(return.value) ^ endif string event.type(LEN_TYPE) | event type from event long retl | return value to be checked retl = datrgevent.get.event.type(io.event, event.type) ERROR_IF(retl <> 0, -2) on case event.type case "delete": retl = move.old.values.to.new.values(io.event) ERROR_IF(retl <> 0, -3) break case "change": | delete old values retl = remove.old.values(io.event) ERROR_IF(retl <> 0, -4) break default: | no action for "create" except setting event type endcase retl = datrgevent.set.event.type(io.event, "takeAction") ERROR_IF(retl <> 0, -5)
注意
この例には、移動/削除関数の実装の詳細は含まれていません。
| |||