xsl-list
[Top] [All Lists]

Re: [xsl] [Xslt 3 Start] Use case for Function Call Invocation

2021-02-04 03:46:45
Ok, thanks for these explanations. I was stuck to XSL usage.

Christophe

Le 04/02/2021 à 09:52, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de a 
écrit :


On 04.02.2021 09:25, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de wrote:


On 04.02.2021 09:07, Christophe Marchand cmarchand(_at_)oxiane(_dot_)com wrote:

Hello !

Reading the recommandation, I was not able to imagine a use-case for Function Call Invocation <https://www.w3.org/TR/xslt-30/#invoking-initial-function>[1].

Recommandation only speeks of raw result, and 2.3.5 section does not mention a "starting environment".

Saxon implementation does not provide a command-line way to start a XSL with a function call invocation ; there is only an API method to do so. And in this case, a XDM value is return.

Could W3C Xslt group members explain the motivation of such a starting way ?

Does someone has a real use-case of this invocation ?

Best regards,
Christophe

[1] : https://www.w3.org/TR/xslt-30/#invoking-initial-function


If you have a module/a function library you can use a function of it with e.g.

let $xslt := <xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="3.0"> <xsl:import href="http://www.xsltfunctions.com/xsl/functx-1.0.1-nodoc.xsl"/>
<xsl:expose component="function" names="*" visibility="public"/>
</xsl:package>
return
transform(
    map {
        'stylesheet-node' : $xslt,
        'initial-function' : QName('http://www.functx.com', 'repeat-string'),
        'function-params' : ['x', 5]
    }
)?output


The XQuery part to first construct an XSLT 3 package importing the XSLT 2 functx library is only necessary as the XSLT 2 functions are otherwise not public. If you had an XSLT 3 version of functx with public functions you would just use the module with e.g. the transform function.


So the general use case is being able to call public functions from XSLT 3 modules or packages directly from environments like XPath 3.1, XQuery 3.1 or XSLT 3, another shorter example would be to call the csv:parse function in the package example of the XSLT 3 spec from pure XPath 3.1


transform(
    map {
        'stylesheet-location' : 'https://github.com/w3c/xslt30-test/raw/master/tests/decl/package/package-100.xsl',
        'initial-function' : QName('http://example.com/csv', 'parse'),
        'function-params' : [data]
    }
)?output

XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2837134> (by email <>)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>