Project

Profile

Help

Two questions on asynchronous SaxonJS.transform

Added by Martin Honnen almost 4 years ago

I have two question on using SaxonJS.transform asynchronously:

  1. Will the returned Promise only be fulfilled after any scheduled ixsl:schedule-action have returned and any result documents created that way exist? Or does the Promise call its then method just when the principal result document has been created/returned?
  2. In the browser, is using xsl:result-document method="adaptive" build-tree="no" supported to collect non-node XDM values? I am having a hard time getting anything like that to work and always get messages like "A map can't be a child of an XML node", although I am trying hard in the XSLT not to create any nodes.

Replies (3)

Please register to reply

RE: Two questions on asynchronous SaxonJS.transform - Added by Michael Kay almost 4 years ago

Regarding (1) there's a difference here between the browser and Node.js. I believe the situation is that in Node.js, the promise is fulfilled when all scheduled actions and all result documents have been completed. On the browser, I don't think we currently wait for scheduled actions to complete. It's complicated by the fact that with an HTTP request, ixsl:schedule-action immediately returns the XmlHttpRequest object to allow the request to be cancelled.

Regarding (2) I think the key thing here is to specify destination="raw" at the API level. But it's entirely possible that there are combinations that aren't working, so if you send us a repro we'll take a look at it.

RE: Two questions on asynchronous SaxonJS.transform - Added by Martin Honnen almost 4 years ago

If the asynchronous transform in the browser doesn't wait for any scheduled actions, how would I be able to capture any xsl:result-document in a scheduled action that doesn't try to write to a HTML DOM element with e.g. href="#foo"? I thought the Promise returns a result object with a resultDocuments property but if any scheduled result documents are not returned by that Promise from transform how could they be handled at all?

RE: Two questions on asynchronous SaxonJS.transform - Added by Michael Kay almost 4 years ago

In the browser, result documents produced by the original thread should be there when transform() returns. xsl:result-document instructions executed following an ixsl:schedule-action exist only for their side effects, typically on the HTML page. I think that's the situation.

Yes, we know this needs improving! I'm doing a Balisage paper next month with my thinking on this.

    (1-3/3)

    Please register to reply