Closed cmarchand closed 7 years ago
Thoses solution add a bit of complexity for users, i'm wondering if there ain't a easyer solution based on automatic casting (based on the @as attribute) ?
As far as I know it's possible to pass saxon any atomic parameters to an xsl from the command line.
For example :
java -jar saxon.jar -s:xml.xml -xsl:xsl.xsl foe=true
foe parameter will be cast as xs:boolean if it's declared that way within the xslt.
You can also write :
java -jar saxon.jar -s:xml.xml -xsl:xsl.xsl foe=1
which will give the same bahaviour as long as Saxon will cast the passed value to xs:boolean
(I guess it would work with any atomic values such as xs:integer, xs:date, etc.)
If it's possible to do something similar in Gaulois Pipe, I would suggest this direction. Just declare the name and type of the param in the conf the same way as in xslt :
<param name="foe" as="xs:boolean"/>
(and maybe adding a required
attribute too ?)
About the select
or value
attribute, I would also do the same as xsl : only select
with the ability to add quotes in the expression to say it's a string :
<param name="foe" as="xs:string" select="'foo'"/>
But if you really need backward compatbiliy then keep the value
attribute for string values and the select
for xpath.
Would it make sens that the expression in select
could be read from an xml stream (as xpath needs a context) ? or do you just mean to use only xs types values ?
In xproc, any variable is evaluated against an xml stream (you can change the implicit one by adding a p:pipe
element inside the p:variable
)
Hope this helps and that I'm not out of topic !
Thanks @matthieuRicaudDussarget , sure it helps !
Release 1.03.00
All parameter values defined from command-line or from configuration file are always treated as xs:string.
If a xsl defines a parameter :
it is impossible to give a correct value to this parameter.
We need a way to type a parameter, at least from configuration file :
I use
@select
here to say that it must be evaluated, where the@value
is only a value thit is not evaluated. This to keep backward compatibility.To define a param from command line, it'll be much more difficult ; a possibility will be to define an abstract typed parameter in configuration file, without any
@value
or@select
, and to evaluate the command-line parameter according to this abstract definition :@matthieuRicaudDussarget : I'd like your opinion on this, please...