After you write user-defined extension classes and set up JARs in WorkSpace, you must inform the transformation service Expression editor that your functions are available for use in transformations. You accomplish this by editing the expressions.xml file.
To edit an expression XML file:
Open the following file:
<installation directory>\WorkSpace\sybase_workspace\services\eclipse\plugins\com.sybase.stf.services.editor.transform_<version number>\grammar\expressions.xml
Edit the file. Inside the <Functions></Functions> element, add the following XML code:
<Function name="MyExtensionFunctions.MyFunction"
where name = <some grouping id, typically your Java classname>.<function name>
type="string"
where type = <any XSD schema data type for the return value of the function>
id="Fun.MyExtensionFunctions.MyFunction.1"
where id = Fun.<grouping id function name>.<instance of this function>
Use the instance value to distinguish overloaded functions.
isInToolPalette="true"
where isInToolPalette = true if the function appears in the Tool Palette and Expression editor context menu.
toolPalettePageID="Custom Functions"
where toolPalettePageID is the name for the tool palette page (or category).
This will create a new page if the page does not already exist. Each new name creates a new page.
toolPaletteLabel="My Function"
where toolPaletteLabel is a label for the function icon in the Tool Palette or Expression Editor context menu.
toolPaletteType="Custom.Fun.MyExtensionFunctions.MyFunction.1"
where toolPaletteType is <Tool Palette group ID>.Fun.<grouping ID>.<function name>.<instance of this function>.
toolPaletteDescription="This is the MyFunction custom function that does x, y, and z."
where toolPaletteDescription is a label for ToolTip (hover) help.
toolPaletteIconPath="icons/temp48.gif">
where toolPaletteIconPath = the name of any icon that is in the <install directory>\sybase_workspace\integration\eclipse\plugins\com.sybase.stf.editors.rule_<version number>\icons path.
<Extension
library="com.mycompany.custom"
where library if the package containing your custom Java class.
prefix="myco"/>
where prefix is a namespace prefix used to distinguish this class of functions.
Do not use syexts, which is reserved for Sybase-delivered extensions.
<Argument name="str1"
where name is an arbitrary name associated with the function's argument.
<Function name="MyExtensionFunctions.MyFunction"
where name is a grouping ID, such as your Java classname and function name.
type="string"
where type is any XSD schema data type for the argument type.
minOccurs="1" maxOccurs="1"/>
Repeat the <Argument> element for each argument required by the function.
</Function>
Close and relaunch Sybase WorkSpace to reload the expressions.xml file.
In your Sybase project, create a new Transformation service.
In the Transformation Service editor, map some or all of the elements from your source to your target schema.
Click on a link to load the default rule.
The Expression editor canvas displays.
When the Tool Palette appears, select your Tool Palette tab.
The Tool Palette has the same name as the toolPalettePageID you defined in the XML.
In the Tool Palette, find your function. It is now ready to use.
Defining a Transformation Rule on a Map Link
Developing Custom Classes for Transforming Message Definition Fields
Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com