Page 1 of 1

Get input values for $ask from another file

Posted: Sun Oct 20, 2019 1:02 am
by JulieP
Hello,

I want to use the $ask variable to provide a drop-down menu with a large number of options. It would be easier to maintain this list in a separate file rather than in the template. Could the list of real and rendered values be pulled from a separate file?

Re: Get input values for $ask from another file

Posted: Mon Oct 21, 2019 12:27 pm
by alex_jitianu
Hello,

You can use an ${oxy_xpath()} in place of the value enumeration, something like this:

Code: Select all

${ask(
'combobox with quotes', 
combobox,
 (${xpath_eval(string-join(for $e in doc('URL_MAPPED_IN_A_CATALOG')//entry return concat('"', $e/text(), '":"', $e/@label, '"'), ';'))})}
In the example above I made the assumption that the values file looks like this:

Code: Select all

<root>
    <entry label="L1">V1</entry>
    <entry label="L2">V2</entry>
</root>
You can add an entry in a catalog file to identify the values file. The catalog can sit inside the framework and be added in the Catalogs tab. This way you can avoid specifying hard coded absolute paths that wont work on every machine, as well as relying on relative paths that might not resolve to the expected base.

Best regards,
Alex

Re: Get input values for $ask from another file

Posted: Mon Oct 21, 2019 7:11 pm
by JulieP
Thank you, Alex!