https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2021-06-09T09:21:56ZSaxonica Developer CommunitySaxonJS - Bug #5017: Fix Accept header value sent by document()https://saxonica.plan.io/issues/5017?journal_id=180592021-06-09T09:21:56ZDebbie Lockettdebbie@saxonica.com
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>In Progress</i></li><li><strong>Assignee</strong> set to <i>Debbie Lockett</i></li></ul><p>I believe you are running in the browser rather than on Node.js?</p>
<p>In the browser, for asynchronous loading, you generally will be using <code>ixsl:schedule-action/@document</code> to load a document before a call to <code>document()</code>. However there is no mechanism for specifying content negotiation here. (Updating <code>ixsl:schedule-action</code> to allow this would be complicated; and we can't just amend the internal implementation as suggested because we do want to use this mechanism for loading a variety of file types.)</p>
<p>Another option (available on Node.js as well as the browser) is to use <code>SaxonJS.getResource</code>, and then supply the preloaded resources for the <code>SaxonJS.transform</code> using the <code>documentPool</code> (or <code>textResourcePool</code>) option. <a class="issue tracker-2 status-3 priority-2 priority-default closed" title="Status: Closed" href="https://saxonica.plan.io/issues/4748">Feature #4748: Option to supply Accept header in SaxonJS.getResource()</a> should allow the Accept header to be supplied; but I'm reopening that issue, because it looks like the fix was incomplete.</p>
<p>In the meantime, could you rework your code to use <code>ixsl:schedule-action/@http-request</code> instead? Here you can specify the full HTTP request, including the headers. I guess a problem might be that the response document will not be in the standard document pool, so you won't be able to just use <code>document()</code> as before. It is just returned in the <code>body</code> of the HTTP response map. (See <a href="https://www.saxonica.com/saxon-js/documentation/index.html#!development/http" class="external">https://www.saxonica.com/saxon-js/documentation/index.html#!development/http</a>)</p> SaxonJS - Bug #5017: Fix Accept header value sent by document()https://saxonica.plan.io/issues/5017?journal_id=180612021-06-09T09:29:29ZMartynas Jusevicius
<ul></ul><p>Yes running in the browser.</p>
<p>This issue mostly concerns templates shared between the server-side (Saxon-HE) and the client-side (Saxon-JS). Where Saxon-HE succeeds loading XML using <code>document()</code>, Saxon-JS fails due to the underspecified <code>Accept</code> header.</p>
<p><code>ixsl:schedule-action</code> is not applicable if the template has to work on the server-side; the <code>documentPool</code> helps but some URLs might not be known in advance (at Saxon-JS initialization time).</p>
<p>Would it be hard to change the default <code>Accept</code> header value? :) Or set it to the same that Saxon-HE sends?</p> SaxonJS - Bug #5017: Fix Accept header value sent by document()https://saxonica.plan.io/issues/5017?journal_id=183092021-08-17T16:33:06ZDebbie Lockettdebbie@saxonica.com
<ul><li><strong>Category</strong> set to <i>API</i></li><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Resolved</i></li><li><strong>Fix Committed on JS Branch</strong> <i>2</i> added</li></ul><p>Code updated in BrowserPlatform.js (in <code>asyncGet</code> and <code>readFile</code> methods), to update the default <code>Accept</code> header as suggested. We now use <code>Accept: application/xml, text/xml;q=0.9, application/xhtml+xml;q=0.8, */*;q=0.7</code>.</p>
<p>Browser tests API/document01 and document02 added (testing both synchronous and asynchronous document fetching).</p> SaxonJS - Bug #5017: Fix Accept header value sent by document()https://saxonica.plan.io/issues/5017?journal_id=183192021-08-20T12:42:46ZDebbie Lockettdebbie@saxonica.com
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Fixed in JS Release</strong> set to <i>Saxon-JS 2.3</i></li></ul><p>Bug fix applied in the Saxon-JS 2.3 maintenance release.</p> SaxonJS - Bug #5017: Fix Accept header value sent by document()https://saxonica.plan.io/issues/5017?journal_id=183312021-08-20T12:43:48ZDebbie Lockettdebbie@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li></ul>