Get input values for $ask from another file

Oxygen general issues.
JulieP
Posts: 16
Joined: Sat May 30, 2015 2:18 am

Get input values for $ask from another file

Post 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?
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Get input values for $ask from another file

Post 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
JulieP
Posts: 16
Joined: Sat May 30, 2015 2:18 am

Re: Get input values for $ask from another file

Post by JulieP »

Thank you, Alex!
Post Reply