Passing a "callback" name to ixsl:schedule-action
Martynas Jusevičius <martynas-tyFqBaoSXPC1Z/[email protected]>
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <CAE35VmxOG=X6O+Jthoe3i7U2F7REJtFBwrMeg6Z+c9k_0PeKzQ@mail.gmail.com> |
Hi,
with Saxon-CE I've used a typeahead "library" which would accept both
the JS function to be called and the callback as params:
<!-- caller -->
<xsl:call-template name="typeahead:load-xml">
<xsl:with-param name="element" select="."/>
<xsl:with-param name="query" select="$text"/>
<xsl:with-param name="uri" select="$results-uri"/>
<xsl:with-param name="js-function" select="$js-function"/>
<xsl:with-param name="callback" select="ixsl:get(ixsl:window(),
'onresourceTypeaheadCallback')"/>
</xsl:call-template>
<!-- library -->
<xsl:template name="typeahead:load-xml">
<xsl:param name="element" as="element()"/>
<xsl:param name="uri" as="xs:anyURI"/>
<xsl:param name="query" as="xs:string"/>
<xsl:param name="js-function" as="xs:string"/>
<xsl:param name="callback"/>
<!-- if the value hasn't changed during the delay -->
<xsl:if test="$query = $element/ixsl:get(., 'value')">
<xsl:value-of select="ixsl:call(ixsl:window(), $js-function, [
ixsl:event(), $uri, $callback ])"/>
</xsl:if>
</xsl:template>
Now I want to replace all custom HTTP-related functions with
<ixsl:schedule-action http-request="">. So I picture something like
this:
<xsl:template name="typeahead:load-xml">
<xsl:param name="element" as="element()"/>
<xsl:param name="uri" as="xs:anyURI"/>
<xsl:param name="query" as="xs:string"/>
<!-- if the value hasn't changed during the delay -->
<xsl:if test="$query = $element/ixsl:get(., 'value')">
<xsl:schedule-action http-request="map{ 'method': 'GET',
'href': $uri, 'headers': map{ 'Accept': 'application/rdf+xml' } }">
<xsl:call-template name="?????????"/>
</ixsl:schedule action>
</xsl:if>
</xsl:template>
So <xsl:call-template> functions like a callback here, but I cannot
pass template name as a param. Of course I could hardcode some name
like "typeahead:xml-loaded", but I would prefer not doing that.
Is there an idiomatic Saxon-JS solution to this?