String Substitutions
Simple templates are simply strings with curly-braces for substituting variable data.
For example:
"The number of unique assignees is {uniqueAssigneeCount}."
will be converted to:
"The number of unique assignees is 32."
after template substitution.
Allowed Substitutions
The following substitutions are provided.
AspireObject Variables
All variables stored with an AspireObject are directly accessible.
For example:
"The number of unique assignees is {uniqueAssigneeCount}."
will be converted to:
"The number of unique assignees is 32."
Objects are converted using the "toString()" method on the object.
AspireObject XML tags
XML tags within the AspireObject can be directly accessed with {XML:tag}.
For example:
"data/vector/{XML:APPLICANT_ID}.vec"
will be converted to:
"data/vector/3290423.vec"
This is only available for tags which are direct children of the root-level <doc> tag.
AspireObject XPATH
Any XML within the document can be accessed using {XPATH:/path/to/element}.
For example:
"data/{XPATH:/doc/categories/category[@id='32']}/myfile.cat"
will be converted to:
"data/jobs/myfile.cat"
(assuming that <categories>/<category id="32">jobs</category></categories> exists within the document)
This is only available for tags which are direct children of the root-level <doc> tag.
Current Date & Time
This is available with {now(date-pattern)}. For example:
"data/logfile-{now(yyyy-MM-dd)}.txt"
will be converted to:
"data/jobs/2010-11-06.txt"
The default format for text is "yyyy-MM-dd'T'HHmmss'Z'". Therefore:
"data/logfile-{now()}.txt"
will be converted to:
"data/jobs/2010-11-06T133800Z.txt"
Note that all dates and times are specified in GMT, always.
For more information on the date format, see [SimpleDateFormat].
Job ID
To get the Job ID, use the literal {JOBID}. For example:
"data/logfile-{JOBID}.txt"
will be converted to:
"data/jobs/CRAWLER-0932-32.txt"
Using Simple Templates
To use the simple templates in custom Groovy/Java code:
import com.searchtechnologies.aspire.framework.SimpleTemplate; SimpleTemplate simpleTemplate = new SimpleTemplate("data/logfile-{JOBID}.txt"); result = simpleTemplate.evaluate(job);
What is Not Available
Note that this is a simple templating capability. Many items are not available, including:
- if statements
- loops
- arbitrary math (other than what's available in XPATH)
- string manipulations (other than what's available in XPATH)