Feature #6355
closedA new instruction that makes a document available by the document() function
100%
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()
, andunparsed-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>
Updated by Michael Kay 10 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.
Updated by Martynas Jusevicius 10 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.
Updated by Debbie Lockett 6 months ago
- Category set to IXSL extensions
- Status changed from New to Resolved
- Assignee set to Debbie Lockett
- Applies to JS Branch Trunk added
- Fix Committed on JS Branch Trunk added
Rather than add a new instruction, I think it is better (and easier) to update the existing syntax to enable this.
I have added a new option for the HTTP client, which allows users to specify that they want the content of a successful response to be added to one of the internal resource pools. For instance, adding 'pool':'xml'
to the HTTP request map means that a successfully loaded document will be added to the documentPool
, making it available to a document()
call.
Updates committed on the main (SaxonJS3) branch:
- implementation in Fetch.js (
httpRequestPromise
andprepareRequest
) - tests added: in
nodejs/schedule
(forixsl:schedule-action/@http-request
); innodejs/schedule-v3
(forixsl:promise
andixsl:http-request()
);browser/iss6355
(forixsl:promise
andixsl:http-request()
) - documentation update in
development/http
section
Updated by Debbie Lockett 3 days ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in JS Release set to SaxonJS 3.0
Bug fix applied in the SaxonJS 3.0.0-beta1 preview release.
Updated by Debbie Lockett 2 days ago
I previously neglected to add a note in the change history section of the documentation about this new addition to the HTTP API. This has now been added, and pushed directly to the SaxonJS 3 documentation online (via the www-saxonica-com
repo).
Please register to edit this issue
Also available in: Atom PDF Tracking page