Editing the Expressions XML File

Edit the expressions.xml after you write user-defined extension classes and set up JARs to inform the transformation service Expression editor that your functions are available for use in transformations.

  1. Open the <installation directory>\WorkSpace\sybase_workspace\services\eclipse\plugins\com.sybase.stf.services.editor.transform_<version number>\grammar\expressions.xml file.
  2. 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>

    Note: 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 creates 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>
    
  3. Close and relaunch Sybase WorkSpace to reload the expressions.xml file.
  4. In your Sybase project, create a new service with a Transformation binding.
  5. In the Service editor, map some or all of the elements from the source to the target schema.
  6. Click on a link to load the default rule.
  7. When the Tool Palette appears, select the Tool Palette tab.

    The Tool Palette has the same name as the toolPalettePageID you defined in the XML.

  8. In the Tool Palette, find your function.

    It is now ready to use.

Related tasks
Modifying the Tool Palette
Writing User-Defined Extension Classes
Adding a User-Defined Extension Function JAR

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.