Re: [Saxon-JS 2] Types of events Saxon-JS cannot handle?

Martynas Jusevičius <martynas-tyFqBaoSXPC1Z/[email protected]> Fri, 11 Sep 2020 00:30:13 +0200
Newsgroups gmane.text.xml.saxon.help
Message-ID <CAE35VmzbVcRC9XSNo69PQT17cTsFvbMKn+f+dL1N1namC0Y5Fg@mail.gmail.com>
I was trying to use SaxonJS.transform() instead and it looked like I
got it to work, but something weird is happening.

This following code is invoked from JS on form submit. It does
successfully replace the form contents, but after each transform all
the ixsl: events seem to get registered one more time for the main
HTML document. E.g. I click a button and it fires 2 times after one
form submit, 3 times after 2 submits etc.

    SaxonJS.transform({
        "stylesheetLocation":
"https://localhost:4443/static/com/atomgraph/linkeddatahub/xsl/client.xsl.sef.json",
        "initialMode":
"Q{https://w3id.org/atomgraph/linkeddatahub/domain#}ConstructViolation",
        "logLevel": 10,
        "sourceNode": html,
        "templateParams": {
            "submitted-form": form
        }
    }, "async");

    <xsl:template match="html" mode="apl:ConstructViolation">
        <xsl:param name="submitted-form" as="element()"/>
        <xsl:variable name="violation-form" as="element()">
        ...
        </xsl:variable>

        <xsl:result-document href="#{$submitted-form/@id}"
method="ixsl:replace-content">
            <xsl:copy-of select="$violation-form/*"/>
        </xsl:result-document>
    </xsl:template>

Could this be related to this text under Result delivery: "When one of
the above values is used, then after updating the HTML page with the
results of the initial transformation, Saxon-JS registers event
listeners with the browser so that template rules with an "ixsl" mode
become responsive to user-input events occurring in the HTML page."?
That the the ixsl: events get registered again and again?

Can this be avoided? I haven't supplied the "destination" param but
the default looks to be "application", which does not mention
registering events.

On Thu, Sep 10, 2020 at 11:13 AM Debbie Lockett <[email protected]> wrote:
>
> TBH I am not that familiar with the Saxon-CE API. But basically it looks to me like SaxonJS.transform() replaces Saxon-CE's XSLT20Processor transform methods updateHTMLDocument(), transformToDocument() and transformToFragment().
>
> That updateHTMLDocument documentation page says:
>
> updateHTMLDocument() is most commonly used with xsl:result-document to update parts of the document identified by the href attribute. The principal XSLT output (if any) is inserted at the end of the HTML body element.
>
> In a Saxon-JS transform you can certainly use xsl:result-document to insert fragments of HTML into the HTML page, in the same way the updateHTMLDocument did. See https://www.saxonica.com/saxon-js/documentation/index.html#!browser/result-documents. If you additionally want the principal XSLT output (principal result tree) to be added at the end of the HTML body, then in Saxon-JS you need to specify the `destination: "appendToBody"` option for SaxonJS.transform(). (See "Result delivery" at https://www.saxonica.com/saxon-js/documentation/index.html#!api/transform).
>
>
> On 09/09/2020 21:05, Martynas Jusevičius wrote:
>
> Thanks, Debbie.
>
> On a related topic, what would be an alternative of Saxon-CE
> updateHTMLDocument() in Saxon-JS 2?
> https://www.saxonica.com/ce/user-doc/1.1/index.html#!api/xslt20processor/updateHTMLDocument
>
> --
> Debbie Lockett
> Saxonica
>
> _______________________________________________
> 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