scripting the resolver with Velocity "Template" attribute defintion

Peter Schober peter.schober at univie.ac.at
Tue Feb 14 14:04:28 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?

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>
  <SourceAttribute>StaffEmail</SourceAttribute>
</AttributeDefinition>

That's probably not surprising, as it looks nothing like the
ECMAScript ones with their addValue() method calls, etc. So far I'm
pulling in attributes via the SourceAttribute child elements, but
producing an empty attribute only:

Attribute Definition 'mail': Determing value 1
Attribute Definition 'mail': Adding value staff at example.edu' for attribute 'StaffEmail' to the template context
Attribute Definition 'mail': Evaluating template
Attribute Definition 'mail': Result of template evaluating was ''
Attribute Definition produced an attribute with the following values [EmptyAttributeValue{value=ZERO_LENGTH_VALUE}]
Attribute definition 'mail' produced an attribute with 1 values

Any suggestions?

Cheers,
-peter


More information about the users mailing list