Using both Ask and Xpath_eval Editor Variables

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Ali-a
Posts: 5
Joined: Tue May 05, 2020 7:34 am

Using both Ask and Xpath_eval Editor Variables

Post by Ali-a » Wed Jun 03, 2020 6:54 pm

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: 316
Joined: Mon May 09, 2016 9:37 am

Re: Using both Ask and Xpath_eval Editor Variables

Post by sorin_carbunaru » Thu Jun 04, 2020 9:16 am

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: 5
Joined: Tue May 05, 2020 7:34 am

Re: Using both Ask and Xpath_eval Editor Variables

Post by Ali-a » Wed Jun 10, 2020 6:59 am

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: 316
Joined: Mon May 09, 2016 9:37 am

Re: Using both Ask and Xpath_eval Editor Variables

Post by sorin_carbunaru » Wed Jun 10, 2020 9:55 am

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.

Post Reply