Project

Profile

Help

Support #4491

closed

Saxon-JS cannot locate the document('/floorplan.svg') path relative to current web page

Added by Gary Cornelius about 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
2020-03-21
Due date:
% Done:

0%

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

Description

When I use the document() function in saxon-js to try to access a relative file path on the web server It cannot find the path as I expected and I need to put a full path in with the domain to make it work. I think this may be a bug or if not it would be a nice feature to add the context here!

I noticed this when I call a function requesting the path along the lines...

[...] <xsl:result-document href="#svg" method="ixsl:replace-content"> <xsl:copy-of select="foo:output-svg(.)"/> </xsl:result-document> [...]

The function then must have the full path using the function as follows:

<xsl:function name="foo:output-svg" expand-text="no"> <xsl:param name="content"/>
<xsl:apply-templates mode="svg" select="document('/floorplan.svg')"/> </xsl:function>

Actions #1

Updated by Debbie Lockett about 4 years ago

  • Tracker changed from Bug to Support
  • Status changed from New to In Progress

Yes, you need to be careful using relative URIs. Please see the information under "Relative URIs" at http://www.saxonica.com/saxon-js/documentation/index.html#!development/source-documents. In particular, the last paragraph:

"We recommend using absolute URIs rather than relative URIs to avoid any mix up - for instance resolve against ixsl:location() to fetch a document relative to the HTML page, using doc(resolve-uri($relativeURI, ixsl:location())) rather than doc($relativeURI) (which will be resolved against the static-base-uri())."

So rather than using a relative path, always construct the right absolute path yourself. There's also an example under http://www.saxonica.com/saxon-js/documentation/index.html#!ixsl-extension/functions/location

Actions #2

Updated by Michael Kay about 4 years ago

Note that doc(), and document#1 when given a string literal argument, resolve against the static base URI of the stylesheet. This in turn depends on whether you specified -relocatable when compiling the stylesheet. Generally a lot of the W3C spec is written on the assumption that the stylesheet is executed at the same location where it is compiled, and we've had to adapt the rules for a different scenario.

Note also that document() also has a two-argument form, so rather than use resolve-uri() explicitly, you can also specify the node whose base URI is to be used in the second argument.

Actions #3

Updated by Debbie Lockett almost 4 years ago

  • Status changed from In Progress to Resolved
Actions #4

Updated by Michael Kay almost 4 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF Tracking page