The global constraints encapsulate the global composition rules for the features in a feature model. This page describes in detail how global constraints can be expressed within XFeature and how compliance with them can be checked.
A complete model of a product family consists of the list of all the features that may appear in applications instantiated from the family, together with a list of the composition rules that define the legal combinations of features that may appear in an application.
Two types of composition rules can be distinguished.
At first sight, the approach sketched in the previous section cannot accommodate global composition rules. It uses XML documents to express both the family and the application models and it automatically derives an XML schema from the family model. The relationship of instantiation between the family model and the application model is then expressed by saying that the XML document representing the application model must be validated by this XML schema. This approach has the virtue of simplicity but is limited by the expressive power of an XML Schema which allows only comparatively simple composition rules to be expressed. In practice, it is only local composition rules that can be easily expressed.
The use of an XML-language to express the application model, however, opens the way to more sophisticated approaches to expressing global composition rules. Arguably, the most obvious and the most flexible way to do so is to encode the general constraints as XSL programs that are run on the XML-based model of the application and produce an outcome of either constraint satisfied or constraint not satisfied. Such an approach is powerful but has the drawback that it requires the family designer to be proficient in XSL.
In order to avoid this drawback while still exploiting the power of XSL to express general feature composition constraints, an alternative approach has been selected where the global composition constraints are expressed in a dedicated language and a compiler is then provided to translate the constraint model expressed in this language into an XSL program that checks compliance with the constraints at application model level.
For consistency with the overall XML-based approach, the language to express the global constraints is an XML-based language defined with XML Schema and the compiler for the constraint model is an XSL program. The following terminology is used in the rest of this document:
XFeature contains a global constraint meta-model encoded as an XML Schema that defines an XML-based
language to define global constraints. The file src/general_files/GlobalConstraintsMetaModel.xsd
contains the formal language definition.
Users define a global constraint model as an XML document that must be validated by the global constraint meta-model. This constraint model expresses the global constraints that apply to a particular feature model. The XFeature tool uses the global constraint model compiler to process the constraint model and to generate the global constraint checker.
The global constraint meta-model allows four types of global constraints to be expressed:
RequiresConstraint
feature is understood as follows:
There is a feature Feature
in the framework model that requires one or
more RequiredFeatures
to be toggled on.ExcludeConstraint
defines a set of two or more Feature
elements that
are mutually exclusive each other.Element
node represents either a toggle feature in the target framework
feature diagram (its presence) or feature value. Each Element
has its Name
(by which is referenced in CustomCondition
) and its Value
that uniquely identifies
the feature (or its value) using XPath syntax. The CustomCondition
is expressed
as a logical expression above elements or arithmetic expressions some operands of which
some are elements.
It is expected that most users will only need the first three types of constraints.
The XFeature tool uses the global constraint model compiler to process the constraint model and to generate the global constraint checker. The global constraint checker is an XSL program that can be run on the target feature model to verify that it satisfies its global constraints.
The global constraint compiler is not a single file. Rather it is a set of XSL programs that work together to transform the global constraints defined for some particular family to XSL program. Implementation of the global constraint model compiler is fairly complex and involves about a dozen of files. The whole pocess is illustrated in the following figure and explained below.
The above figure illustrates how global constraints compiler is implemented
within the XFeature tool. Once user finished definition of the family feature
model MyFamily.xfm
along with global constraints of the family
MyFamily.xgc
the
global constraint checker can be generated in the following steps (see the left
half of the above figure).
MyFamily.xfm
is processed by an XSL program
*XfmNamesTranaslator.xsl
. This XSL program is specific to
an XFeature configuration. In the above figure IcsrXfmNamesTranaslator.xsl
is used suggesting that ICSR configuration was used to desing the
MyFamily.xfm
family model.
This *XfmNamesTranaslator.xsl
XSL program assigns an XPath expression
to each node in the family feature model. The assigned XPath is such that
it will point to its node in application feature models that belong to the
family defined in MyFamily.xfm
.
The output of the transformation is saved in temporary file
gcValueTmp.xfm
.
MyFamily.xgc
is processed by XgcNamesTransaltor.xsl
XSL program that
takes gcValueTmp.xfm
as a parameter and generates
temporary file gcValueTmp.xgc
. The input and output
files are almost identical, the only difference is that the
XPath expression used in MyFamily.xgc
to identify features
are replaced by the XPath expression assigned to the respective nodes
by configuration specific *XfmNamesTranaslator.xsl
script
in the previous step.
ClobaConstriantsCompiler.xsl
takes the modified global
constraints definition gcValueTmp.xgc
and generates
global constraint checker which is a XSL program names
MyFamilyApp.xgcc
in the figure. The name of the file
is user defined and it is the same as the application meta model
file name (except the extension, of course).
The global constraint checker is then used by XFeature when application feature model is being validated. The validation of global constraints is done in two steps.
MyApplication.xfm
are translated to be the same
as in family feature model and global constraint definition. This
is done by generic xfmReomveUniquenames.xsl
script which
is delivered with XFeature and is configuration neutral. The trasnforamtion
results in temporary file gcValueAppTmp.xfm
.
gcValueAppTmp.xfm
is processed
by global constraint checker
MyFamilyApp.xgcc
.
The XSL program logs all constraint checks to a text file and ends
silently if all checks pass. In case of global constraint violation
it immediately reports the error and quits the execution.
There is a demonstration that presents how the global constraint framework is
used withing the XFeature tool in the user manual. Note that the user is
not required to understand the implementation detail described in this section
in order to use global constraint in his/her feature models. All it takes is to
locate the *XfmNamesTranaslator.xsl
file in the folder corresponding
to the current XFeature configuration.