Bug #4183
closedCannot pass output parameters and document node parameters across the command line.
100%
Description
Good Afternoon,
I am writing some XSLT tests and need to pass in a parameter that is an XML chunk. Reading the command line documentation I found that +param= is suppose to load and parse a file, perfect for what I need. Trying it didn't work for net.sf.saxon.Transform. I could not even get it to error with a "File Not Found" error if I misspelled the file name.
Downloading the source code I found the following:
The entry point Transform.java calling main, calls doTransform, which calls setActualOptions in trans/CommandLineOptions.java. That sets up paramFiles with the correct param names, and the associated filename/directoryname/URI.
paramFiles is processed in trans/CommandLineOptions.java in setParams, but that function is never called from Transform, it is only called from Query. Instead some parameters are being set by applyStaticParams, which is also in CommandLineOptions.java, which is for XSLT 3.0 (according to the comment) and does half the job of setParams, it sets the simple params -- paramValues, and the expression params, the ones starting with ?, paramExpressions.
applyStaticParams is called from Transform just before loading the source file. Since SetParams is never called, and applyStaticParams does only "half" the job my document node param is never setup.
I am not sure how you would like to solve this, whether changing the code or the documentation, so I do not want to offer any code changes, but I would really like to be able to use the +param= function, it would solve my testing problem.
Thank you for your time, - Michael Caerwyn
Updated by Michael Kay about 5 years ago
Yes, you're quite right.
I think what happened here is that we decided to set all the parameters at compile time, because when you're running from the command line you know all the parameter values at compile time so you might as well let the compiler take advantage of this knowledge. However, node-valued parameters supplied at compile time cause a bit of a problem when the stylesheet is exported (see bug #4035). So this fell through a gap. And unfortunately our test coverage of command line interfaces has always been weak compared with coverage of API invocation.
Updated by Michael Kay over 4 years ago
- Status changed from New to Resolved
- Assignee set to Michael Kay
- Priority changed from High to Normal
- Applies to branch trunk added
- Fix Committed on Branch 9.9, trunk added
I don't know how this issue dropped off the radar for so long, but I have now fixed it. Parameters specified using the +name=value syntax are now applied to the transformation. They are handled at run-time (all other parameters are handled at compile time) to avoid any problems when generating SEF files.
Updated by O'Neil Delpratt over 4 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.9.1.5 added
Bug fix applied in the Saxon 9.9.1.5 maintenance release.
Please register to edit this issue