You can extend the XSLT 1.0 and 2.0 function libraries available in MapForce with your own custom functions, provided that your custom functions return simple types.
Only custom functions that return simple data types (for example, strings) are supported.
To import functions from an XSLT file:
1.On the Tools menu, click Options. (Alternatively, click Add/Remove Libraries in the lower area of the Libraries window.)
2.Next to Libraries, click Add and browse for the .xsl or .xslt file.
Imported XSLT files appear as libraries in the Libraries window, and display all named templates as functions below the library name. If you do not see the imported library, ensure you selected XSLT as transformation language (see Selecting a Transformation Language).
Note the following:
•To be eligible for import into MapForce, functions must be declared as named templates conforming to the XSLT specification in the XSLT file. You can also import functions that occur in an XSLT 2.0 document in the form <xsl:function name="MyFunction">. If the imported XSLT file imports or includes other XSLT files, then these XSLT files and functions will be imported as well.
•The mappable input connectors of imported custom functions depends on the number of parameters used in the template call; optional parameters are also supported.
•Namespaces are supported.
•If you make updates to XSLT files that you have already imported into MapForce, changes are detected automatically and MapForce prompts you to reload the files.
•When writing named templates, make sure that the XPath statements used in the template are bound to the correct namespace(s). To see the namespace bindings of the mapping, preview the generated XSLT code.
Datatypes in XPath 2.0
If your XML document references an XML Schema and is valid according to it, you must explicitly construct or cast datatypes that are not implicitly converted to the required datatype by an operation.
In the XPath 2.0 Data Model used by the Altova XSLT 2.0 Engine, all atomized node values from the XML document are assigned the xs:untypedAtomic datatype. The xs:untypedAtomic type works well with implicit type conversions.
•the expression xs:untypedAtomic("1") + 1 results in a value of 2 because the xdt:untypedAtomic value is implicitly promoted to xs:double by the addition operator.
•Arithmetic operators implicitly promote operands to xs:double.
•Value comparison operators promote operands to xs:string before comparing.