https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2017-05-16T16:32:07ZSaxonica Developer CommunitySaxonJS - Bug #3223: Supplying Document objects to JavaScript global functionshttps://saxonica.plan.io/issues/3223?journal_id=83972017-05-16T16:32:07ZMichael Kaymike@saxonica.com
<ul></ul><p>Note, incase it isn't clear: the XDM data model used in XSLT allows a document node to have multiple element and text node children. That means we have to represent it normally using a DOM DocumentFragment rather than Document object. But if the static type of a variable is declared as document-node(element(X)) then we know that it should be possible to represent it as a DOM Document. Of course we need to make sure that there is sanitary error handling if it's declared as document-node(element(X)) and the code then tries to create multiple element or text node children.</p> SaxonJS - Bug #3223: Supplying Document objects to JavaScript global functionshttps://saxonica.plan.io/issues/3223?journal_id=114862018-04-18T12:07:22ZDebbie Lockettdebbie@saxonica.com
<ul></ul><p>I don't think anything much is going to be changed in the Saxon-JS code on the 1.x branch; but maybe more will be done for 2.0, if we think of anything worthwhile.</p>
<p>It would be good to add a note in the Saxon-JS documentation. In the JS/XDM type conversion section, we currently just say that XDM nodes are converted to DOM nodes. But it may be useful to explain that XDM document nodes are usually converted to DOM DocumentFragment objects rather than DOM Document objects. These can always be converted on the JavaScript side by the user if necessary, using something like:</p>
<pre><code>if (item instanceof DocumentFragment) {
var docNode = document.implementation.createDocument(null, null, null);
var n = docNode.importNode(item, true);
docNode.appendChild(n);
return docNode;
}
</code></pre>
<p>To fix the problem I had with XMLHttpRequests, I think we should update the specification for HTTP request maps supplied to ixsl:schedule-action/@http-request, to clarify that $request?body must be a document node (the documentation currently says any item is allowed); with a check in the JS code to throw a sensible error if it is not (at the moment the XMLHttpRequest may just crash out with an internal error).</p> SaxonJS - Bug #3223: Supplying Document objects to JavaScript global functionshttps://saxonica.plan.io/issues/3223?journal_id=114882018-04-18T14:26:01ZDebbie Lockettdebbie@saxonica.com
<ul><li><strong>Applies to JS Branch</strong> <i>1.0, Trunk</i> added</li></ul><p>Re last point: the type of $request?body is just specified as item because of the different content MIME types (text, multipart, and binary, as well as XML and HTML). We should just say that if the MIME type of the content is XML or HTML, then $request?body must be a document node.</p> SaxonJS - Bug #3223: Supplying Document objects to JavaScript global functionshttps://saxonica.plan.io/issues/3223?journal_id=115022018-04-20T13:48:05ZDebbie Lockettdebbie@saxonica.com
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Fix Committed on JS Branch</strong> <i>1.0, Trunk</i> added</li></ul><p>Type check for $request?body added to BrowserPlatform.makeHTTPrequest as described.</p>
<p>Notes added to documentation as suggested.</p>
<p>As Mike suggested in Note 2, we could do more if the static type of a variable is declared as document-node(element(X)), in which case we know that it should be possible to represent it as a DOM Document, rather than just a DocumentFragment. But I don't think we have to (as long as this is documented).</p> SaxonJS - Bug #3223: Supplying Document objects to JavaScript global functionshttps://saxonica.plan.io/issues/3223?journal_id=115792018-05-09T10:21:03ZDebbie Lockettdebbie@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li><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 1.1.0</i></li></ul><p>Bug fix applied in the Saxon-JS 1.1.0 maintenance release.</p>