Editing the Expressions XML File

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:

  1. Locate the folder where the Sybase WorkSpace plugins are installed, for example, c:\sybase\workspace\Eclipse\services.

  2. Navigate to the com.sybase.stf.services.editor.transform_n.n.n plugin and edit the grammar\expressions.xml file in the appropriate editor.

  3. 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>

    Note

    Use the instance value to distinguish overloaded functions.

    isInToolPalette="true"

    where isInToolPalette = true if the function should appear 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 = <a label for the function icon in the Tool Palette or Expression Editor context menu>.

    toolPaletteType="Custom.Fun.MyExtensionFunctions.MyFunction.1"

    where toolPaletteType = <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 = <a label for ToolTip (hover) help>

    toolPaletteIconPath="icons/temp48.gif">

    where toolPaletteIconPath = <the name of any icon that is in the <install dir>\sybase_workspace_1.0\integration\eclipse\plugins\com.sybase.stf.editors.rule_0.0.2\icons path>

    <Extension

    library="com.mycompany.custom"

    where library = <the package containing your custom Java class>

    prefix="myco"/>

    where prefix = <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 = <an arbitrary name associated with the function's argument>

    <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 argument type>

    minOccurs="1"
    maxOccurs="1"/>

    Repeat the <Argument> element for each argument required by the function.

    </Function>
  4. Restart Sybase WorkSpace.

    This reloads the expressions.xml file.

  5. In your Sybase project, build a new Transformation service.

  6. In the Transformation Service editor, map some or all of the elements from your source to your target schema.

  7. Click on a link to load the default rule.

    The Expression editor canvas displays.

  8. 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.

  9. 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