xsltaltovamap-force

MapForce - Add dayTimeDuration to dayTimeDuration


I am trying to use mapforce to generate an xslt 2.0 file. The mapping is adding 2 dayTimeDuration elements, doing so results in the following error;

No match for core.add(xs:dayTimeDuration, xs:dayTimeDuration). Check argument types. Supported: +(xs:double, xs:double) -> xs:double

I thought that xslt 2.0 supported adding 2 dayTimeDurations. Is there a way of doing this using mapforce?

Cheers Stew


Solution

  • Had almost the same problem, first tried to add functx-library but saw it creates absolute path in the generated xslt2-code, which isn't very good.

    Well, turns out you can implement that function, but first you have to do some modifications...

    Find your Mapforce installation directory, and MapForceLibraries -subdirectory. From that open the "core.mff", and find

    <group name="math functions">
        <component name="add" growable="true" growablebasename="value">
            <sources>
                <datapoint name="value1" type="xs:decimal"/>
                <datapoint name="value2" type="xs:decimal"/>
            </sources>
            <targets>
                <datapoint name="result" type="xs:decimal"/>
            </targets>
    

    As you can seem the "sources" and "targets" elements seems to define the in- and out data types. As it is, they have only implemented "add"-function for "xs:decimal". You can copy/paste this component, then rename it and give new in- out- data types, in your case they are both "xs:dayTimeDuration". Note that there are implementations for each supported language, but you can omit those that are not needed. Here's what should work:

    <component name="addDayTimeDuration" growable="true" growablebasename="value">
        <sources>
            <datapoint name="value1" type="xs:dayTimeDuration"/>
            <datapoint name="value2" type="xs:dayTimeDuration"/>
        </sources>
        <targets>
            <datapoint name="result" type="xs:dayTimeDuration"/>
        </targets>
        <implementations>
            <implementation language="xslt">
                <operator value="+"/>
            </implementation>
            <implementation language="xslt2">
                <operator value="+"/>
            </implementation>
            <implementation language="builtin">
                <function name="Core_Add"/>
            </implementation>
        </implementations>
        <description>
            <short>result = value1 + value2</short>
            <long>Result is the dayTimeDuration value of adding value1 and value2.</long>
        </description>
    </component>
    

    Your new function should now appear in the "math functions" and should be good to use.