Using both Ask and Xpath_eval Editor Variables

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Ali-a
Posts: 6
Joined: Tue May 05, 2020 7:34 am

Using both Ask and Xpath_eval Editor Variables

Post by Ali-a »

I want to ask the user for the url of an image, the image always starts with 'ish:/' and so I want to use the substring-after the 'ish:/' as the url path. I'm attempting to do that with the fragment insertion below in an Oxygen action. However, the syntax is incorrect and I'm wondering if I should nest the $ask inside of a xpath_eval. What is the best way to go about this?

Code: Select all

<image href="${ask('please choose image path', ${xpath_eval(substring-after(url,'ish:/')))}"/>
Thanks,
Ahmed
sorin_carbunaru
Posts: 384
Joined: Mon May 09, 2016 9:37 am

Re: Using both Ask and Xpath_eval Editor Variables

Post by sorin_carbunaru »

Hello Ahmed,

What you want to do is to first get the URL from the user and then process that URL. So, this means that first you should use $ask and then $xpath_eval to process the user input.

Code: Select all

${xpath_eval(substring-after('${ask('Please choose image path:', generic)}','ish:/'))}
Please note that substring-after seems to require that the first argument is surrounded by quotes. Also make sure you close all the parentheses and curly brackets.

Regards,
Sorin Carbunaru
oXygen XML
Ali-a
Posts: 6
Joined: Tue May 05, 2020 7:34 am

Re: Using both Ask and Xpath_eval Editor Variables

Post by Ali-a »

Thanks Sorin,

I get the following error when using what you have posted. I'm not sure if the syntax is still correct, there are apostrophes nested within apostrophes?

Code: Select all

:Paste failed due to: Unmatched closing ')' near index 6
.+=',''))}=.=en-US=High.png
Thanks,
Ahmed
sorin_carbunaru
Posts: 384
Joined: Mon May 09, 2016 9:37 am

Re: Using both Ask and Xpath_eval Editor Variables

Post by sorin_carbunaru »

Hello Ahmed,

With Oxygen XML Editor 22.x it works fine on my side. What version of Oxygen do you have installed?

By the way, if it seems the problem comes from using nested quotes, try using double quotes when inside quotes, or the other way around.

Best wishes,
Sorin C.
Ali-a
Posts: 6
Joined: Tue May 05, 2020 7:34 am

Re: Using both Ask and Xpath_eval Editor Variables

Post by Ali-a »

Hello Sorin,

Coming back to this after all this time. I'm using Oxygen 20 now and have attempted using your line of code in the

Code: Select all

<image href="${xpath_eval(substring-after('${ask('Please choose image path:', generic)}','ish:/'))}"/>
I have also attempted it with the substring-after nested inside of the {ask}. Either way I can only get the outside function to work and not both.

Thanks,
Ahmed
sorin_carbunaru
Posts: 384
Joined: Mon May 09, 2016 9:37 am

Re: Using both Ask and Xpath_eval Editor Variables

Post by sorin_carbunaru »

Hello,

If I'm not mistaken, constructions such as your only started working fine after Oxygen 21.1. Please try with a newer version of Oxygen (you could use a trial version of 22.1) and let me know how it goes.

Sorin C.
Post Reply