Re: [Saxon-JS 2] Callback template param value

Martynas Jusevičius <martynas-tyFqBaoSXPC1Z/[email protected]> Tue, 29 Sep 2020 15:05:57 +0200
Newsgroups gmane.text.xml.saxon.help
Message-ID <CAE35VmwM-vg3Qs4McTB5E5KGV22QBk95NB6X5YudUL1KGj6d-Q@mail.gmail.com>
Thanks, I can stop banging my head against the wall :)

Should I open a ticket?

Is there a workaround?

On Tue, Sep 29, 2020 at 2:27 PM Michael Kay <[email protected]> wrote:
>
> I guess the value of the variable has changed between the xsl:schedule-action being evaluated, and the xsl:call-template being evaluated when the action completes, and we haven't been clear enough in the documentation (or indeed, in our own minds) about how that's supposed to work.
>
> Certainly it would be much better if we evaluated the with-param values at the time the action is scheduled, not at the time it completes, and we need to look into that.
>
> Thanks for pointing it out.
>
> Michael Kay
> Saxonica
>
> On 29 Sep 2020, at 12:04, Martynas Jusevičius <[email protected]> wrote:
>
> Hi,
>
> I don't get how this happens -- why is the same param value passed to
> the callback template when I would expect 3 different values?
>
> <xsl:template>
>    ...
>    <xsl:variable name="facet-bgps"
> select="$select-xml//json:map[json:string[@key = 'type'] =
> 'bgp']/json:array[@key =
> 'triples']/json:map[not(starts-with(json:string[@key = 'predicate'],
> '?'))][starts-with(json:string[@key = 'object'], '?')]"
> as="element()*"/>
>    <xsl:for-each select="$facet-bgps">
>        <xsl:sort select="ac:property-label(json:string[@key = 'predicate'])"/>
>        <xsl:variable name="bgp" select="." as="element()"/>
>        ...
>        <xsl:variable name="results-uri" select="..." as="xs:anyURI"/>
>
>        <xsl:message>
>        PREDICATE: <xsl:value-of select="$bgp/json:string[@key = 'predicate']"/>
>        </xsl:message>
>
>        <ixsl:schedule-action http-request="map{ 'method': 'GET',
> 'href': $results-uri, 'headers': map{ 'Accept':
> 'application/sparql-results+xml' } }">
>            <xsl:call-template name="onFacetValueResultsLoad">
>                <xsl:with-param name="container-id" select="$container-id"/>
>                <xsl:with-param name="bgp" select="$bgp"/>
>            </xsl:call-template>
>        </ixsl:schedule-action>
>    </xsl:for-each>
> </xsl:template>
>
> <xsl:template name="onFacetValueResultsLoad">
>    <xsl:context-item as="map(*)" use="required"/>
>    <xsl:param name="container-id" as="xs:string"/>
>    <xsl:param name="bgp" as="element()"/>
>
>    <xsl:message>
>    PREDICATE IN CALLBACK: <xsl:value-of select="$bgp/json:string[@key
> = 'predicate']"/>
>    </xsl:message>
>    ...
>
> This is the output I get:
>
> xsl:message:
>            PREDICATE: http://purl.uniprot.org/core/organism
> xsl:message:
>            PREDICATE: http://purl.uniprot.org/core/encodedBy
> xsl:message:
>            PREDICATE: http://www.w3.org/2000/01/rdf-schema#label
> xsl:message:
> PREDICATE IN CALLBACK: http://www.w3.org/2000/01/rdf-schema#label
> xsl:message:
> PREDICATE IN CALLBACK: http://www.w3.org/2000/01/rdf-schema#label
> xsl:message:
> PREDICATE IN CALLBACK: http://www.w3.org/2000/01/rdf-schema#label
>
> 3 different values in the calling template, the same 1 value in the
> callback template.
> How is that possible?
>
>
> Martynas
>
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help