Re: Passing a "callback" name to ixsl:schedule-action

Graydon <[email protected]>
Newsgroups gmane.text.xml.saxon.help
Message-ID <20200830215735.GA41041@menja>
On Sun, Aug 30, 2020 at 02:35:11PM -0700, Dimitre Novatchev scripsit:
> On Sun, Aug 30, 2020 at 2:03 PM Alan Painter <[email protected]> wrote:
> > You don't need to have a hard-coded template name or even a named template.
> >
> > Instead, you can use xsl:apply-templates and select an element that you
> > have constructed to have the name passed from a parameter.
> > This will select a "match" template on an element with that name (and,
> > optionally, with a given namespace).
> >
> > This gives you the equivalent of calling an arbitrarily named template but
> > via match templates.
>
> FXSL ?    :)

Or modes.

Where you'd call the function you have:

<xsl:variable name="this" as="document-node()"
select="namespace:function($params)"/>
<xsl:apply-templates mode="write-file" select="$this"/>

and somewhere else you've got:

<xsl:template mode="write-file" match="/">
    <xsl:result-document....
        <xsl:sequence select="."/>
    </xsl:result-document>
</xsl:template>

You can stack modes on the main writing template if they turn out to all
be the same, or mostly the same, so you only need as many file-writing
templates as you've actually got cases. Apply-templates takes parameters
if you need to pass things to the "commit result-document" template from
where the function gets called.

-- 
Graydon Saunders  | [email protected]
Þæs oferéode, ðisses swá mæg.
-- Deor  ("That passed, so may this.")
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.