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 » 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: 330
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: 6
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: 330
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.

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

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

Re: Using both Ask and Xpath_eval Editor Variables

Post by sorin_carbunaru » Fri Aug 21, 2020 9:08 am

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