scripting the resolver with Velocity "Template" attribute defintion
Cantor, Scott
cantor.2 at osu.edu
Tue Feb 14 14:14:15 EST 2017
> I'm exploring (cough!) the use of Velocity for simple scripting within
> the attribute resolver, e.g. in order to avoid any Java Rhino/Nashorn
> issues. Is this supposed to work for creating attributes within
> "Template" attribute definitions and how?
I have one that contains this (all on one line):
<![CDATA[#if ($term_code == 0)${role}@urn:mace:osu.edu:course:${enroll_yyyyq_code}:${subject}:${catalog_num}#else${role}@urn:mace:osu.edu:course:${enroll_yyyyq_code}.${term_code}:${subject}:${catalog_num}#end]]>
My recollection is that it was pretty important that it stay on one line, but if I was willing to live with it, I could do mostly anything the template language allowed.
> The simplest possible test case didn't work:
>
> <AttributeDefinition id="mail" xsi:type="Template">
> <Dependency ref="someSource" />
> <Template>#set ($mail = 'foo at example.org')</Template>
You don't need to assign the result, the whole string that is returned from evaluating the template is what gets used as the value, which is why you have to be very careful with what it's evaluating into.
-- Scott
More information about the users
mailing list