Project

Profile

Help

Bug #5476

open

xsl:result-document doesn't function properly

Added by Lou Burnard 10 days ago. Updated 7 days ago.

Status:
AwaitingInfo
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2022-05-06
Due date:
% Done:

0%

Estimated time:
Found in version:
Fixed in version:
Platforms:

Description

I upgraded to SaxonC-HE 11.3 and several things stopped working. One I have not yet found a workround for is a stylesheet which calls xsl:result-document, supplying a bare filename as the value for @href. The intention is to create this file in the current directory (obvs) but the context for that to be done seems to be missing. If the filename supplied does NOT already exist I get diagnostics like this:

Error in xsl:result-document/@href on line 72 column 58 of reporter.xsl: SXRD0002 The system identifier of the principal output file is unknown In template rule with match="/" on line 31 of reporter.xsl None Error in file(file, "rt", encoding = fileEncoding) : cannot open the connection Calls: read.table -> file In addition: Warning message: In file(file, "rt", encoding = fileEncoding) : cannot open file 'metadata.csv': No such file or directory Execution halted

but if the file DOES exist (and should therefore be over-written) all I get is

Error in xsl:result-document/@href on line 72 column 58 of reporter.xsl: SXRD0002 The system identifier of the principal output file is unknown

Either way, this is not what should be happening.

Actions #1

Updated by Martin Honnen 9 days ago

Just to understand, where did you update from, from 11.2 to 11.3? Or some earlier version?

Also, is the problem occurring when running the command line tool transfom/transform.exe or when you write your own code (in what language, using which API)?

I think the consensus of the Saxonica guys for the API use is that you have to make sure you set the base output URI e.g. https://www.saxonica.com/saxon-c/doc11/html/saxonc.html#PyXsltExecutable-set_base_output_uri, https://www.saxonica.com/saxon-c/doc11/html/classXsltExecutable.html#abd5af13644ffedaa3c1baa3a380eb563 to have relative result document URIs working.

So if you are using the PHP or Python or C++ API and haven't explicitly set the base output URI then try whether that fixes your problem, at least as a workaround.

Actions #2

Updated by Martin Honnen 9 days ago

Another option to approach the problem from the XSLT side is to use e.g. <xsl:result-document href="{resolve-uri('output.xml', static-base-uri())}"> instead of <xsl:result-document href="output.xml">, that way you don't need to change the PHP or C++ or Python code.

Actions #3

Updated by Michael Kay 9 days ago

You say "the intention is to create the file in the current directory". In that case you need to ensure that the "base output URI" is the URI of the current directory. There is a method Xslt30Processor::setBaseOutputURI() for achieving this.

This should defaults to the directory containing the principal output file, if there is one.

I think it's right that we're careful about this: writing files to an unintended location, especially when it overwrites an existing file at that location, is a dangerous thing to do, so it makes sense to ask the user to be very explicit about it.

Actions #4

Updated by Lou Burnard 9 days ago

Thanks for the helpful comments and suggestions.But since you ask, I must have been using a VERY old version of the python API before, because many of the method names seem to have changed or disappeared(e.g. there was something called xsltproc.set_initial_match_selection(file_name=DRIVERFILE) which there no longer is). . But in any case, explicitly setting the base URI seems the best solution: I would like to be able to use my XSL scripts via any interface not just the python one. I'll get back to you if this is still a problem! (I was confused because the stylesheet works as intended when invoked from command line saxon but failed when using the python api.

Actions #5

Updated by O'Neil Delpratt 9 days ago

Hi,

Please see the following page on the API changes: https://www.saxonica.com/saxon-c/documentation11/index.html#!changes

The set_initial_match_selection method is on the PyXsltExecutable class. You first have to compile a stylesheet using PyXslt30Processor class.

The XsltExecutable class has been introduced across all APIs (C++, Python and PHP) to facilitate the execution of compiled stylesheets. This works alongside the Xslt30Processor class which is used to compile stylesheets.

Actions #6

Updated by O'Neil Delpratt 7 days ago

  • Status changed from New to AwaitingInfo

Please register to edit this issue

Also available in: Atom PDF