XProc Option Setup

Questions about XML that are not covered by the other forums should go here.
scottbdr
Posts: 50
Joined: Tue Jul 21, 2009 1:48 am

XProc Option Setup

Post 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
Mircea
Posts: 131
Joined: Tue Mar 25, 2003 11:21 am

Re: XProc Option Setup

Post by Mircea »

Hello Scott,

The correct usage for the $date() editor variable is:

Code: Select all

${date(yyyy-MM-dd'T'HH:mm)}
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.
Mircea Enachescu
<oXygen> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
scottbdr
Posts: 50
Joined: Tue Jul 21, 2009 1:48 am

Re: XProc Option Setup

Post 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
2022-09-16 08_06_44-Start.png (33.32 KiB) Viewed 1616 times
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
Mircea
Posts: 131
Joined: Tue Mar 25, 2003 11:21 am

Re: XProc Option Setup

Post 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.
Mircea Enachescu
<oXygen> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
scottbdr
Posts: 50
Joined: Tue Jul 21, 2009 1:48 am

Re: XProc Option Setup

Post by scottbdr »

That works! Thank you! (might want to update your docs a bit if its not in there somewhere - that's tricky...)
Mircea
Posts: 131
Joined: Tue Mar 25, 2003 11:21 am

Re: XProc Option Setup

Post by Mircea »

Hi Scott,

the complete list of editor variables and usage is located here.

Regards
Mircea.
Mircea Enachescu
<oXygen> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
scottbdr
Posts: 50
Joined: Tue Jul 21, 2009 1:48 am

Re: XProc Option Setup

Post 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
Mircea
Posts: 131
Joined: Tue Mar 25, 2003 11:21 am

Re: XProc Option Setup

Post by Mircea »

Hi Scott,

I understand, that is an excellent remark !
We will do that change in documentation for sure !

Regards,
Mircea.
Mircea Enachescu
<oXygen> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply