RE: Yet Another V2 Request: Extension Functions via XSLT 2

> -----Original Message-----
> From: James Fuller [mailto:jim@webcomposite.com]
> Sent: Thursday, August 08, 2013 12:12 PM
> To: Toman, Vojtech
> Cc: XProc WG
> Subject: Re: Yet Another V2 Request: Extension Functions via XSLT 2
> 
> that sounds like an interesting approach, though a little confused.
> 
> I could see usefulness in being able to invoke steps themselves;
> 
>     my:newstep($inputs as map:map, $outputs as map:map, $options as
> map:map)
> 
> but that doesn't make it entirely clear how functions in xquery/xslt
> libs would be loaded into the in scope environment.
> 
> so I will make a strawman;
> 
> <p:xquery>
> <p:input port="library">
>    <p:document href="myxquerylib.xqy"/>
>    <p:document href="myotherxquerylib.xqy"/> </p:input> </p:xquery>
> 
> this could have the advantage of also loading in libs for the step
> itself (instead of import in xquery)
> 
> and in the above form (w/ no query port binding), it could load into in
> scope environment.
> 
> thoughts ?

My idea was much simpler. Instead of importing the XSLT/XQuery functions directly, you would do that in XSLT/XQuery and then wrap the function you need you need in a separate p:xslt/p:xquery step:

<p:declare-step name="my:great-function">
  ...
  <p:xquery>
    <p:input port="query">
      <p:inline>
        <c:query>
          import module namespace my='...' at '...';
          my:great-function(...)
        </c:query>
      </p:inline>
    </p:input>
  </p:xquery>
</p:declare-step>

This approach has obvious limitations (verbose; the need for a separate step for each function; etc.), but it could do for simple things. Actually, if we wanted to support import XQuery/XSLT modules directly via p:import/p:document/etc., this could be, conceptually, what the processor does behind the scenes to expose those functions the XProc context.

The question of how to invoke XProc steps in XPath expressions is another story. Passing maps for ports and options is one possibility, but perhaps we could do something simpler (by restricting ourselves to pipelines with certain signatures) and more XPath-y.

Regards,
Vojtech

--
Vojtech Toman
Consultant Software Engineer
EMC | Information Intelligence Group
vojtech.toman@emc.com
http://developer.emc.com/xmltech

Received on Thursday, 8 August 2013 12:08:16 UTC