Page 1 of 1
XProc Option Setup
Posted: Tue Sep 13, 2022 10:41 pm
by scottbdr
Hi, I'm trying to set up an option in an XProc Transform dialog that uses the ${ask(...)} editor variable.
I'm trying to get a default value set as timestamp is in this format: 'YYYY-MM-DDTHH:MM'.
What I've tried thus far is:
Code: Select all
${ask( 'Set build date as',generic,${date('yyyy-MM-ddTHH:MM')})}
${ask('Set build date as',generic,${xpath_eval(format-dateTime(current-dateTime(),'[Y0001]-[M01]-[D01]T[h01]:[m01]'))})}
Neither seem to work. Not sure whether these editor variables just don't work for XProc or if I have some sort of syntax error.
I also noticed a few other things with the XProc implementation:
1) If you pass an empty option value via an ${ask()} dialog, the default 'select' value declared on the p:option is not honored
2) in the XProc editor, you have to save before the validation is updated (which is not the case in other editors)
Not sure if that's per design or not but both seem inconvenient...
Thanks, Scott
Re: XProc Option Setup
Posted: Fri Sep 16, 2022 11:55 am
by Mircea
Hello Scott,
The correct usage for the
$date() editor variable is:
Use this, and the correct behavior will occur.
Validation as you type is also available in the XProc editor, and should work for your document as well.
Regarding the empty option value via an ${ask()} dialog, I will investigate further and see if there is a problem on our side or on Calabash.
Regards,
Mircea.
Re: XProc Option Setup
Posted: Fri Sep 16, 2022 6:30 pm
by scottbdr
Thanks for the reply Mircea. I tried the new date format in this:
Code: Select all
${ask('Set build date as',generic,${date(yyyy-MM-dd'T'HH:mm)})}
with no success:
2022-09-16 08_06_44-Start.png
Regarding validation, is there some sort of switch that turns it on/off for a particular editor type? I have "Enable Automatic Validation" set and I'm absolutely certain that I can type an erroneous XProc pattern and does not red-line it until I save, and any fix requires a save to updated as well. Not the case in my other editors, just XProc.
Thanks, Scott
Re: XProc Option Setup
Posted: Wed Sep 21, 2022 12:04 pm
by Mircea
Hi Scott,
This is the correct writing of the editor variable:
Code: Select all
${ask( 'Set build date as',generic,'${date(yyyy-MM-dd'T'HH:MM)}')}
The call for
${date(yyyy-MM-dd'T'HH:MM)} must be surrounded by apostrophes as well since it is expanded on the second iteration of the expression.
Regards,
Mircea.
Re: XProc Option Setup
Posted: Wed Sep 21, 2022 6:39 pm
by scottbdr
That works! Thank you! (might want to update your docs a bit if its not in there somewhere - that's tricky...)
Re: XProc Option Setup
Posted: Thu Sep 22, 2022 11:41 am
by Mircea
Hi Scott,
the complete list of editor variables and usage is located
here.
Regards
Mircea.
Re: XProc Option Setup
Posted: Thu Sep 22, 2022 7:24 pm
by scottbdr
Yes, I was using that page and generally I find that documentation excellent - I was referring to the fact that there is only a single example showing that sort of quoting (the very last line of the article) and no indication otherwise that parameters using editor variables will need to be quoted.
My suggestion might be a Note directly after the first Note on the page saying something like:
NOTE: The use of editor variables within a parameter of another editor variable must be within single quotes for them to be properly expanded. Example:
Code: Select all
${ask( 'Provide a date',generic,'${date(yyyy-MM-dd'T'HH:MM)}')}
It just makes that fact a bit more visible... I'm sure to some folks it's a bit more obvious but obviously I never got around to trying it that way until you told me!
It's interesting the quotes around the T don't have to be escaped somehow or be doubles - I'd think the parser might stumble on that. It works though...
Scott
Re: XProc Option Setup
Posted: Fri Sep 23, 2022 8:14 am
by Mircea
Hi Scott,
I understand, that is an excellent remark !
We will do that change in documentation for sure !
Regards,
Mircea.