Export Variables and Content Dependencies

By means of export variables you can store values in layouts so that they can be used as often as desired, either in the same or other layout files. In some circumstances the use of export variables generates content dependencies which slow down the export. This section explains the technical details and shows how content dependencies can be avoided.

An export variable can be created in two ways:

<!-- First method -->
<npsobj insertvalue="var" name="export.myvar"/>
<!-- Second method -->
<npsobj insertvalue="var" name="myvar"/>

If the first method is used, the export only checks whether an export variable named myvar exists. If it does, its value is inserted into the file being exported. If not, this is assumed to be an error. With the second method, however, the export will try to find a field named myvar if there is no such export variable. If this field exists, its value is inserted into the export file. Unless this field has been registered as a reference field in export.referenceAttributes, a content dependency is triggered.

Unfortunately, the first method does not work up to version 6.7.1 if the export variable contains a file or link context and if you wish to access a field of this context.

File context example:

<npsobj modifyvar="clear" varname="myObject" />
<npsobj context="/public/index.html">
  <npsobj modifyvar="append" varname="myObject" name="self" />
</npsobj>

<!-- not possible up to version 6.7.1: -->
<npsobj insertvalue="var" name="export.myObject.path" />

Link context example:

<npsobj modifyvar="clear" varname="myLink" />
<npsobj list="relatedLinks" length="1">
  <npsobj modifyvar="append" varname="myLink" name="self" />
</npsobj>

<!-- not possible up to version 6.7.1: -->
<npsobj insertvalue="var" name="export.myObject.destinationUrl" />

In this case you can – to avoid content dependencies – check whether the variable is empty prior to accessing the field:

File context:

<npsobj condition="isNotEmpty" name="export.myObject">
  <npsobj insertvalue="var" name="myObject.path" />
</npsobj>

Link context:

<npsobj condition="isNotEmpty" name="export.myLink">
  <npsobj insertvalue="var" name="myLink.destinationUrl" />
</npsobj>

From version 6.7.2, you can use the export prefix when accessing fields of a context stored in an export variable.