1

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

stew
  • 87
  • 2
  • 8
  • https://www.w3.org/TR/xpath-functions-30/#func-add-dayTimeDurations suggests it is possible. I have no idea about MapForce. Perhaps it is better to ask in their support forum. – Martin Honnen Feb 05 '16 at 09:17
  • Martin, thanks for confirming at it is possible in xslt 2.0. I have it posted on their forum but haven't had any replies. – stew Feb 08 '16 at 00:30

2 Answers2

1

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.

Tuomas
  • 93
  • 9
0

After contacting Altova (the makers of MapForce); While XPath 2 does offer a subtract-dayTimeDurations operation, this is not presently offered as a function inside MapForce.

stew
  • 87
  • 2
  • 8
  • Well, you can always do it yourself. – michael.hor257k Feb 08 '16 at 22:53
  • Yes, I hand wrote the xslt and imported it as a library. The problem now is that MapForce is putting the absolute path to the library, which is fine for development but not so good for production. – stew Feb 08 '16 at 23:02
  • Altova's response to the absolute path issue; That's not presently possible. You'll have to edit the generated XSLT. I'll forward that issue on to our development team for future consideration, as well. – stew Feb 10 '16 at 04:37