Project

Profile

Help

Feature #6355

open

A new instruction that makes a document available by the document() function

Added by Martynas Jusevicius 2 months ago. Updated 2 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2024-02-20
Due date:
% Done:

0%

Estimated time:
Applies to JS Branch:
2
Fix Committed on JS Branch:
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

ixsl:schedule-action supports @document and @http-request. Both approaches have their advantages. For @schedule-action:

The called template can access the documents using the doc(), document(), doc-available(), json-doc(), unparsed-text(), unparsed-text-available(), and unparsed-text-lines() functions as appropriate (the documents will be found in a local cache and will not involve another request to the server).

For @http-request it's the possibility to fully specify the HTTP request headers. That's what I have been using so har

The problem is that the approaches cannot be combined. In other words, it is not possible to specify HTTP request headers, load documents asynchronously and pass them to templates that use document() What could be the solution to this?

Adding more options to ixsl:schedule-action seems like it would overload the instruction too much. I'm thinking a better idea could be decoupling the HTTP client functionality from the document caching functionality. That could be achieved using a new instruction that caches a document node under the specified URI, thus making it available for document() calls.

For example:

  <xsl:variable name="href" select="http://example.com/doc.xml" as="xs:string"/>
  <ixsl:schedule-action http-request="map{ 'href': $href }">
    <xsl:call-template name="response-callback">
      <xsl:with-param name="href" select="$href"/>
    </xsl:call-template>
  </ixsk:schedule-action>

<xsl:template name="response-callback">
  <xsl:param name="href" as="xs:string"/>

  <ixsl:cache-doc href="$href" select="?body"/>
  <xsl:call-template name="legacy"/>
</xsl:template>

<xsl:template name="legacy">
  <xsl:message select="document('http://example.com/doc.xml')"/> <!-- retrieved from cache -->
</xsl:template>

Actions #1

Updated by Michael Kay 2 months ago

Implementation of a design to replace ixsl:schedule-action and address the issues you raise is well advanced. You can find some of the early thinking here:

https://www.balisage.net/Proceedings/vol25/html/Kay01/BalisageVol25-Kay01.html

though the design has moved on from that starting point, and it won't all be delivered in one go.

Actions #2

Updated by Martynas Jusevicius 2 months ago

Michael, thanks for the update. I'm looking forward for the promise support.

This is about a more trivial issue of making the async-loaded documents accessible using document(). In SaxonJS 2.6, you can either do that or specify the HTTP request headers, but not both.

Please register to edit this issue

Also available in: Atom PDF Tracking page