Use the values of pattern parameters to control whether
a project is created when a pattern user generates an instance of
a user-defined pattern.
Before you begin
Complete the following tasks:
About this task
You can control whether projects that are selected as source
files in a user-defined pattern are created by using XPath expressions.
For XPath reference information, including information about XPath
functions, see W3C XPath 1.0 Specification.
- The
pp:getValue()
function is included, in addition
to the functions in the XPath 1.0 Specification. The pp:getValue()
function
takes the parameter ID of a pattern parameter and returns the value
of that pattern parameter. To see the parameter ID for a pattern parameter:
- In the Pattern
Configuration tab of the
Pattern Authoring editor, double-click a parameter, or select a parameter
and click Edit. The Edit Parameter window
opens.
- Click the Transform tab. The parameter
IDs for pattern parameters are shown in the Parameter ID column
of the Pattern Parameters table.
- When a pattern instance is generated by a pattern user, transformation
expressions are processed before any Java™ and
PHP code that has been added to modify pattern instances. Transformation
of pattern parameters is processed in the following sequence:
- Every parameter that has an XPath transformation expression is
evaluated.
- The value of each parameter that has an XPath transformation expression
is updated with the result of its evaluation, overwriting the value
entered by the pattern user.
- The parameters are evaluated in top to bottom order, as they are
listed in the Pattern
Configuration tab of the
Pattern Authoring editor.
Procedure
To control project creation by using an XPath expression:
- Open the Pattern Authoring editor.
- In the Source tab, in the Select
Source Files section, double-click the project that you want to control,
or select the project and click Edit.
The Edit Project window opens.
- Click the Create tab. Create
an XPath expression for your chosen project:
- To select a function:
- Expand Boolean, Number, Pattern,
or String in the Functions section, then click
a function. The function is displayed in the Function name field.
- Click Use. The function is inserted into
the Expression field at the cursor.
- To select an operator:
- Click an operator in the Operators section. The operator is displayed
in the Operator field.
- Click Use. The operator is inserted into
the Expression field at the cursor.
- To select a pattern parameter:
- Click a pattern parameter in the Pattern Parameters table. The
parameter ID shown in the Parameter ID column
of the Pattern Parameters table for the chosen parameter is displayed
in the Parameter ID field.
You
cannot select a pattern parameter that uses a table type.
- Click Use. The parameter ID is inserted
into the Expression field at the cursor.
- You can also edit the expression directly in the Expression field.
- Repeat the actions in step 3,
as required, to create your XPath expression.
- You can now choose whether to test your expression: