https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2016-09-20T17:44:03ZSaxonica Developer CommunitySaxonJS - Bug #2885: Use of URI.jshttps://saxonica.plan.io/issues/2885?journal_id=72152016-09-20T17:44:03ZMichael Kaymike@saxonica.com
<ul></ul><p>I believe the places we use the URI library are:</p>
<p>(a) to implement the resolve-uri() function (CoreFn.js)</p>
<p>(b) in DOMUtils, (baseURI function) to test whether a URI is absolute (and then resolve it if not)</p>
<p>(c) when initiating the transformation, to resolve the supplied stylesheet URI against the URI of the HTML page</p>
<p>When we're in the browser, I think it makes sense to try the resolve-uri() method given here:</p>
<p><a href="http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue" class="external">http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue</a></p>
<p>specifically</p>
<pre><code>function resolve(url, base_url) {
var doc = document
, old_base = doc.getElementsByTagName('base')[0]
, old_href = old_base && old_base.href
, doc_head = doc.head || doc.getElementsByTagName('head')[0]
, our_base = old_base || doc_head.appendChild(doc.createElement('base'))
, resolver = doc.createElement('a')
, resolved_url
;
our_base.href = base_url || '';
resolver.href = url;
resolved_url = resolver.href; // browser magic at work here
if (old_base) old_base.href = old_href;
else doc_head.removeChild(our_base);
return resolved_url;
}
</code></pre>
<p>This essentially adds a <code><base></code> element to the header of the HTML page, and creates an <code><a></code> element containing the relative URI, and then piggy-backs on the fact that the browser knows how to resolve relative URIs in <code><a></code> elements.</p>
<p>We should give this a try. We would still need to use the URI.js library in non-browser environments.</p> SaxonJS - Bug #2885: Use of URI.jshttps://saxonica.plan.io/issues/2885?journal_id=72162016-09-20T17:44:19ZMichael Kaymike@saxonica.com
<ul><li><strong>Tracker</strong> changed from <i>Feature</i> to <i>Bug</i></li></ul> SaxonJS - Bug #2885: Use of URI.jshttps://saxonica.plan.io/issues/2885?journal_id=73962016-10-21T17:13:08ZDebbie Lockettdebbie@saxonica.com
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li></ul><p>BrowserPlatform now has resolveUri method as suggested above. (Note that the JSTestDriver platform used for Nashorn also has a resolveUri method.)</p>
<p>The use of URI.js has now been removed, basically we now use this platform resolveUri method:</p>
<p>(a) resolve-uri() function in CoreFn.js: now does some basic testing that the supplied parameters are valid, then uses the platform.resolveUri method.</p>
<p>(b) baseURI() method in DomUtils: added DomUtils.isAbsoluteURI method which uses regex to check that a string is an absolute URI. Then use platform.resolveUri</p>
<p>(c) initiating transform: in browser uses resolveUri</p> SaxonJS - Bug #2885: Use of URI.jshttps://saxonica.plan.io/issues/2885?journal_id=77002016-12-09T16:13:29ZDebbie 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 version</strong> set to <i>0.9.1</i></li></ul><p>Bug fix applied in the Saxon-JS 0.9.1 beta release.</p> SaxonJS - Bug #2885: Use of URI.jshttps://saxonica.plan.io/issues/2885?journal_id=97462017-08-09T17:55:55ZCommunity Adminsupport@saxonica.com
<ul><li><strong>Fixed in JS Release</strong> set to <i>Saxon-JS 0.9.1</i></li><li><strong>Applies to JS Branch</strong> <i>0.9</i> added</li><li><strong>Fix Committed on JS Branch</strong> <i>0.9</i> added</li></ul>