9.5.  Predefined Source Element Types

Table 9.6. Predefined source element types

Source TypeDescriptionIcon
ps:dir Maps directly to a directory.
ps:file Maps directly to a file.
ps:fragment Represents a file fragment to be appended to another file.
ps:condxml Maps directly to an XML document containing variation points (conditional parts) using XPath expressions.
ps:condtext Maps directly to a text document containing variation points (conditional parts) using XPath expressions.
ps:pvsclxml Maps directly to an XML document containing variation points (conditional parts) using pvSCL expressions.
ps:pvscltext Maps directly to a text document containing variation points (conditional parts) using pvSCL expressions.
ps:flagfile Represents a file that can hold flags such as a C/C++ header file containing preprocessor defines.
ps:makefile Represents a make (build) file such as GNU make files containing make file variables.
ps:classaliasfile Represents a file containing an alias e.g. for a C++ class that can be concurrently used in the same place in the class hierarchy.
ps:symlink Maps directly to a symbolic link to a file.

The following sections provide detailed descriptions of the family model source element types that are relevant for the standard transformation (see Section 6.3.2, “ Standard Transformation ” ).

All file-related source element types derived from element type ps:destfile specify the location of a file using the two attributes dir and file . Using the standard transformation the corresponding file is copied from <ConfigSpaceInputDir>/<dir>/<file> to <ConfigSpaceOutputDir>/<dir>/<file> . Source element types derived from ps:srcdestfile optionally can specify a different source file location using the attributes srcdir and srcfile . If one or both of these attributes are not used, the values from dir and file are used instead. The source file location is relative to the <ConfigSpaceInputDir> .

Attributes:
dir [ps:directory]
srcdir? [ps:directory]

This source element type is used to copy a directory from the source location to the destination location. All included subdirectories will also copied. The optional attribute srcdir ist used for directories that are located in a different place in the source hierarchy and/or have a different name.

Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
srcdir? [ps:directory]
srcfile? [ps:path]

This source element type is used for files that are used without modification. The source file is copied from the source location to the destination location. The optional attributes srcdir and srcfile are used for files that are located in a different place in the source hierarchy and/or have a different source file name.

The value of attribute type should be def or impl when the file contains definitions (e.g. a C/C++ Header) or implementations. For most other files the type misc is appropriate.

TypeDescription
impl This type is used for files containing an implementation, e.g. .cc or .cpp files
def This type is used for files containing declarations, e.g. C++ header files. In the context of ps:classalias calculations this information is used to determine the include files required for a given class.
misc This type is used for any file that does not fit into the other categories.
app This type is used for the main application file.
undefined This type is for files for which no special meaning and/or action is defined.
Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
srcdir? [ps:directory]
srcfile? [ps:path]
mode [ps:insertionmode]
content? [ps:string]
encoding? [ps:encoding]

This source element type is used to append text or another file to a file. The content is taken either from a file if srcdir and srcfile are given, or from a string if content is given. If taken from a string, attribute encoding can be used to specify the character encoding of the string content. The attribute mode is used to specify the point at which this content is appended to the file, i.e. before or after the child parts of the current node's parent part are visited. The default value is before .

Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
srcdir? [ps:directory]
srcfile? [ps:path]
conditionname? [ps:string]
copycondition? [ps:boolean]

This source element type is used to copy an XML document and optionally to save the copy to a file. Special conditional attributes on the nodes of the XML document are dynamically evaluated to decide whether this node (and its subnodes) are copied into the result document. The name of the evaluated condition attribute is specified using the attribute conditionname and defaults to condition . If the attribute copycondition is not set to false , the condition attribute is copied into the target document as well.

The condition itself has to be a valid XPath expression and may use the XSLT extension functions defined in the following namespaces. Calls to these functions have to be prefixed by the given namespace prefix followed by a colon (":"), e.g. F .


For a description of the pure::variants XSLT extension functions see Table 9.10, “Extension functions providing model information” . For a description of the EXSLT extension functions see http://www.exslt.org .

In the example document given below after processing with an ps:condxml transformation, the resulting XML document only contains an introductory chapter if the corresponding feature WithIntroduction is selected.


A special XML node is supported for calculating and inserting the value of an XPath expression. The name of this node is pv:value-of (namespace "pv" is defined as "http://www.pure-systems.com/purevariants"). The expression to evaluate has to be given in the attribute select . The pv:value-of node is replaced by the calculated value in the result document.


Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
srcdir? [ps:directory]
srcfile? [ps:path]
encoding? [ps:encoding]

This source element type is used to copy a text document and optionally to save the copy to a file. Special statements in the text document are evaluated to decide which parts of the text document are copied into the result document, or to insert additional text. If no text document encoding is given, then UTF-8 encoding is assumed.

The statements (macro-like calls) that can be used in the text document are listed in the following table.

MacroDescription
PV:IFCOND( condition ) Open a new conditional text block. The text in the block is included in the resulting text output if the given condition evaluates to true. The opened conditional text block has to be closed by a PV:ENDCOND call.
PV:IFCONDLN( condition )

PV:ELSEIFCOND( condition )

This macro can be used after a PV:IFCOND or PV:ELSEIFCOND call. If the condition of the preceding PV:IFCOND or PV:ELSEIFCOND is failed, the condition of this PV:ELSEIFCOND is checked. If it evaluates to true, the enclosed text is included in the resulting text output.
PV:ELSEIFCONDLN( condition )
PV:ELSECOND This macro can be used after a PV:IFCOND or PV:ELSEIFCOND call. If the condition of the preceding PV:IFCOND or PV:ELSEIFCOND is failed, the enclosed text is included in the resulting text output.
PV:ELSECONDLN
PV:ENDCOND Close a conditional text block. This macro is allowed after a PV:IFCOND , PV:ELSEIFCOND , or PV:ENDCOND call.
PV:ENDCONDLN
PV:EVAL( expression ) Evaluate the given expression and insert the expression value into the result document.
PV:EVALLN( expression )

These macros can occur everywhere in the text document and are directly matched, i.e. independently of the surrounding text. The conditions of PV:IFCOND and PV:ELSEIFCOND and the expression of PV:EVAL are the same as the conditions described for source element type ps:condxml (see Section 9.5.4, “ ps:condxml ” for details).

Conditional text blocks can be nested. That means, that a PV:IFCOND block can contain another PV:IFCOND block defining a nested conditional text block that is evaluated only if the surrounding text block is included in the resulting text output.

For each macro a version with suffix LN exists, i.e. PV:IFCONDLN , PV:ELSEIFCONDLN , PV:ELSECONDLN , PV:ENDCONDLN , and PV:EVALLN . These macros affect the whole line and are only allowed if there is no other macro call in the same line. All characters before and behind such a macro call are removed from the line. It is allowed to mix macros with and without suffix LN , e.g. PV:IFCONDLN can be followed by PV:ENDCOND and PV:IFCOND by PV:ENDCONDLN .

In the example document given below after processing with an ps:condtext transformation, the resulting text document only contains an introductory chapter if the corresponding feature WithIntroduction is selected.


Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
srcdir? [ps:directory]
srcfile? [ps:path]
conditionname? [ps:string]
copycondition? [ps:boolean]
valuesubstitution? [ps:boolean]

This source element type is used to copy an XML document and optionally to save the copy to a file. Special conditional attributes on the nodes of the XML document are dynamically evaluated to decide whether this node (and its subnodes) are copied into the result document. The name of the evaluated condition attribute is specified using the attribute conditionname and defaults to pv:condition . If the attribute copycondition is not set to false , the condition attribute is copied into the target document as well. If the attribute valuesubstitution is set to true , the content of all attribute values of the XML document will be handled as Section 9.5.7, “ ps:pvscltext ” .

The condition itself has to be a valid pvSCL expression. For details on writing pvSCL expressions, see Section 9.7, “Expression Language pvSCL” .

In the example document given below after processing with an ps:pvsclxml transformation, the resulting XML document only contains an introductory chapter if the corresponding feature WithIntroduction is selected.


A special XML node is supported for calculating and inserting the value pvSCL expression. The name of this node is pv:eval (namespace "pv" is defined as "http://www.pure-systems.com/purevariants"). The pv:eval node is replaced by the calculated value in the result document.


Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
srcdir? [ps:directory]
srcfile? [ps:path]
encoding? [ps:encoding]

This source element type is used to copy a text document and optionally to save the copy to a file. Special statements in the text document are evaluated to decide which parts of the text document are copied into the result document, or to insert additional text. If no text document encoding is given, then UTF-8 encoding is assumed.

The statements (macro-like calls) that can be used in the text document are listed in the following table.

StatementDescription
PVSCL:IFCOND( condition ) Open a new conditional text block. The text in the block is included in the resulting text output if the given condition evaluates to true. The opened conditional text block has to be closed by a PVSCL:ENDCOND call.

PVSCL:ELSEIFCOND( condition )

This macro can be used after a PVSCL:IFCOND or PVSCL:ELSEIFCOND call. If the condition of the preceding PVSCL:IFCOND or PVSCL:ELSEIFCOND is failed, the condition of this PVSCL:ELSEIFCOND is checked. If it evaluates to true, the enclosed text is included in the resulting text output.
PVSCL:ELSECOND This macro can be used after a PVSCL:IFCOND or PVSCL:ELSEIFCOND call. If the condition of the preceding PVSCL:IFCOND or PVSCL:ELSEIFCOND is failed, the enclosed text is included in the resulting text output.
PVSCL:ENDCOND Close a conditional text block. This macro is allowed after a PVSCL:IFCOND , PVSCL:ELSEIFCOND , or PVSCL:ENDCOND call.
PVSCL:EVAL( expression ) Evaluate the given pvSCL expression and insert the value of the expression into the result document.

These statements can occur everywhere in the text document and are directly matched, i.e. independently of the surrounding text. The conditions of PVSCL:IFCOND and PVSCL:ELSEIFCOND and the expression of PVSCL:EVAL are the same as the conditions described for source element type ps:pvsclxml (see Section 9.5.6, “ ps:pvsclxml ” for details), except for a list of comma-separated flags that can follow the pvSCL code. Following flags are supported.

FlagDescription
LINE Clear or remove the line containing the pvSCL conditional text statement.

Example for a multi-line if-statement utilizing flag LINE :

/* PVSCL:IFCOND(Temperature,LINE) */
initializeSensor("temperature",PVSCL:EVAL(Temperature->max));
/* PVSCL:ELSECOND */
disableSensor("temperature");
/* PVSCL:ENDCOND */
Result if feature Temperature is selected:
initializeSensor("temperature",60);

Example for a single-line if-statement utilizing flag LINE :

//PVSCL:IFCOND(WindSensor,LINE)updateSensor("wind");PVSCL:ENDCOND
Result if feature WindSensor is selected:
updateSensor("wind");

Conditional text blocks can be nested. That means, that a PVSCL:IFCOND block can contain another PVSCL:IFCOND block defining a nested conditional text block that is evaluated only if the surrounding text block is included in the resulting text output.

In the example document given below after processing with an ps:pvscltext transformation, the resulting text document only contains an introductory chapter if the corresponding feature WithIntroduction is selected.


Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
flag [ps:string]
encoding? [ps:encoding]

This source element type is used to generate C/C++-Header files containing #define <flag> <flagValue> statements. The <flagValue> part of these statements is the value of the attribute Value of the parent part element. The name of the flag is specified by the attribute flag . See the section called “Providing Values for Part Elements” for more details. The same file location can be used in more than one ps:flagfile definition to include multiple #define statements in a single file.


Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
variable [ps:string]
set? [ps:boolean]
makesystem? [ps:makesystemtype]
encoding? [ps:encoding]

This source element type is used to generate makefile variables using a <variable> += '<varValue>' statement. The <varValue> part of the statement is the value of the attribute Value of the parent part element. The name of the variable is specified by the attribute variable . See the section called “Providing Values for Part Elements” for more details. The attribute set defines if the variable is set to the value (true) or if the variable is extended by the value (false). The generated code is compatible with the gmake system. To generate code for a different make system the attribute makesystem can be used. The same file location can be used for more than one ps:makefile element to include multiple makefile variables in a single file.


Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
alias [ps:string]
encoding? [ps:encoding]

This source element type is used to support different classes with different names that are concurrently used in the same place in the class hierarchy. This transformation is C/C++ specific and can be used as an efficient replacement for templates in some cases. This definition is only used in conjunction with the part type ps:classalias . A typedef aliasValue alias; statement is generated by the standard transformation for this element type. aliasValue is the value of the attribute Value of the parent part element. Furthermore, in the standard transformation the Variant Result Model is searched for a class with name aliasValue and #include statements are generated for each of its ps:file source elements that have a type attribute with the value 'def'. If the alias name contains a namespace prefix, corresponding namespace blocks are generated around the typedef statement.


Attributes:
dir [ps:directory]
file [ps:path]
type [ps:filetype]
linktarget [ps:string]

This source element type is used to create a symbolic link to a file or directory named <linktarget> .