Editing CSL Modules
To edit a CSL module, follow these steps:
1 For a global CSL module, navigate to the global CSL modules (see Navigating to Global CSL Modules). Be sure to select the Library CSL tab for library modules and the CSL Modules tab for non-library modules.
For CSL modules associated with a node, navigate to the CSL modules for the node— see Navigating from the Template Graph to the Data for a Given Node.
2 Click the folder icon for the desired module. The module text appears in the editing pane.
3 Select Override Object from the CMWB Edit menu. You can now modify the text. See also Using Completion, below.
4 To add or remove output formulas, select the tab (at the top of the editing pane) for the node associated with the module you are editing. In other words, go back is the screen on which you just clicked the folder icon. Modify the module’s formula table. To add a formula, use the blank line at the end of the table. To remove a formula, right click in it and select Remove.
5 Select Save All from the File menu to save your changes.
6 To incorporate your changes into the cost model, select Publish Cost Model and VPE from the File menu.
Using Completion
The CSL editor supports code completion. Type Ctrl and Space together to pop up a list of suggested completions for the word you are typing.
The list of suggestions includes the following:
CSL predefined (built-in) functions, such as searchString and asList, whose names include the sequence of letters that you have typed so far.
CSL templates, such as select and foreach templates, whose names include the sequence of letters you have typed so far. A CSL template is a canonical example of a CSL construct (such as a select expression). It contains placeholders, which you will replace with expressions of your choice in order to tailor the example to your needs. Note that you can define your own templates in order to supplement the built in, system-supplied templates—see Defining CSL Code Templates.
CSL standard inputs, such as plant and childResults, whose names include the sequence of letters you have typed so far.
The list begins with suggestions that start with the letters typed so far, arranged alphabetically. These are followed by suggestions that include, but don’t start with, the letters typed so far, arranged alphabetically.
Typing Control and Space pops up a list with all suggestions; typing control space additional times toggles through filtered lists:
System-supplied template suggestions
User-defined template suggestions
Built-in function suggestions
Standard input suggestions
All suggestions
The current category of suggestions is displayed in the lower right:
Click on a suggested function or template to display documentation for it.
Double click a suggestion to insert its associated code into the CSL module at the cursor location:
Functions: double click a function suggestion to insert a template for a call to the function. For functions with arguments, you will have to replace the argument-placeholders with the appropriate expressions.
Templates: double click a template suggestion to insert a template for a formula or expression. You will have to replace the placeholders with appropriate expressions.
Inputs: double click an input suggestion to insert it into the code.
You can also use the up/down cursor keys to select an entry (and bring up any associated documentation), and you can press RETURN/ENTER to insert the selected entry’s CSL.
The following shows the associated code for the function searchString, and for the templates select, foreach, and with:
Note that the suggestion list only includes CSL standard inputs when costing is stopped at a CSL breakpoint. The suggestions include only the inputs that are defined or available (that is, in scope) at that point in the cost model execution.
Defining CSL Code Templates
Follow these steps to define a CSL code template:
1 Create a file called user-defined-csl-templates.xml. Do one of the following:
Save the file in the application-data directory of your aPriori installation (for example, in C:\Users\<user>\AppData\Local\aPriori\18.3).
Save the file in a directory of your choice that you can continue to use when you upgrade to new versions of aPirori. Set the property ide.csl.templates.dir in apriori.properties to the path for this directory (see the System Administration Guide).
2 Edit the file to include one templates element, and within that, as subelements, one template element for each template that you want to define. Here is an exmaple:
<templates>
 
   <template name="Basic Template" description="first example">
      <documentation><![CDATA[
         Type some documentation here...
      ]]></documentation>
      <csl>basic.single(line).code.fragment</csl>
   </template>
 
   <template name="Longer Template" description="another example">
      <documentation><![CDATA[
         Type some documentation here...
      ]]></documentation>
      <csl><![CDATA[
         foreach (variable1: select x from collection x) getSum(variable2) {
            variable2 = select x.attribute from variable.collection x
         }
      ]]></csl>
   </template>
 
   ...
 
</templates>
Each template element has the following attributes and subelements:
name: template name
description (optional): short description of the template
documentation (optional): documentation for the template
csl: the template's associated code example
The use of CDATA tags is generally recommended for the documentation and csl elements, in order to avoid problems arising from the use of XML reserved characters in the element's contents.