Page 1 of 1

Using both Ask and Xpath_eval Editor Variables

Posted: Wed Jun 03, 2020 6:54 pm
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

Re: Using both Ask and Xpath_eval Editor Variables

Posted: Thu Jun 04, 2020 9:16 am
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

Re: Using both Ask and Xpath_eval Editor Variables

Posted: Wed Jun 10, 2020 6:59 am
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

Re: Using both Ask and Xpath_eval Editor Variables

Posted: Wed Jun 10, 2020 9:55 am
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.

Re: Using both Ask and Xpath_eval Editor Variables

Posted: Fri Aug 21, 2020 4:21 am
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

Re: Using both Ask and Xpath_eval Editor Variables

Posted: Fri Aug 21, 2020 9:08 am
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.