A completeness check shows if an asset such as a product meets a defined data quality. Set up a Completeness Check asset using an XPATH expression or an XSLT that defines the conditions to be checked.


Context

censhare offers a configurable, automated quality management for your assets, for example for a Product Information Management System (PIM). Quality checks consist of a sequence of quality gates or completeness checks. Quality gates themselves have completeness checks. For example, if a product number exists. A Completeness check asset defines one check. 

This article is about completeness checks.

Prerequisites

Deeper understanding of XPATH and XSLT and how to use them in censhare. These technologies are used to define the conditions in a Completeness check asset. XPATH is also used to define special asset filters.

Introduction

To make sure that an asset contains a defined set of data, for example, a product has an EAN number, you can define a completeness check. The completeness check tests if this information exists in the respective asset. For example, the completeness check tests if a value is stored in the "EAN" property of a product.

A Completeness check asset consists of two main parts. The first part defines by filter for which type of assets the completeness check is applied to. The second part defines the check itself that has to be performed.

Overview: required steps

  • Create a Completeness check asset

  • Configuration part 1: Set the asset type filters. Only these assets will be checked.

  • Configuration part 2: Define the conditions that must be matched to pass the check. Add an XPATH expression or assign an XSLT script. The result of the check is a Boolean (true/false).

Define filters

The filters define, which asset types a completeness check applies to. You can add one or more asset-type filters. To each asset-type filter, you can add one or more MIME-type filters. 

Alternatively, you can define more complex filters using XPATH expressions. For more information, see Working with filters in "Quality gates". 

Define the check

In this part of the completeness check, you define the condition that must be "true" to pass the check. The condition can be set as optional or required. Accordingly, the "Quality gate" widget shows the completeness check in the "Required" or "Optional" sections.

To define a check, you can use an XPATH expression or an XSLT script. If the result of XPATH or the XSLT is true, the check is passed. For simple queries, use XPath. For more complex checks, use an XSLT script.

Instruction text

The "Quality check" widget shows the name of the Completeness check as a list entry. You can use localized names that are shown in the available user interface languages.

The text in the description field is shown as tooltip text of the information button of the completeness check. Enter a short text with instructions how to pass the completeness check. You can use localized descriptions that are shown in the available user interface languages.

XPATH check

With an XPATH expression, you can access any element in the XML of an asset and related assets. 

Here is an example that checks if the EAN property: 

ID = "censhare:product.ean" 

exists in an asset:

exists(asset_feature[@feature='censhare:product.ean']) 

The following two examples check for relations:

exists(child_asset_rel[@key='user.main-picture.'])
exists(parent_asset_re[@key='user.feature-rule.']) 

The first one checks for a child relation with ID "user.main-picture.", the second one for a parent relation with the ID "user.feature-rule.".

You can combine multiple XPATH expressions. The check in the following example is passed if there is no task assigned or the task is done:

not(child_asset_rel[@key='user.task.']) or exists(asset_feature[@feature=
       'censhare:calc-child-task-completion-percentage' and @value_double='100.0']) 

The first part with checks if there is no child task assigned:

not(child_asset_rel[@key='user.task.']) 

The second part checks if the completion state of the child task is 100 percent:

exists(asset_feature[@feature='censhare:calc-child-task-completion-percentage' 
    and @value_double='100.0']) 

XSLT check

The following XSLT script checks if there is a budget for a Marketing plan asset defined. The filter for the asset type is set in the Completeness check asset, not in the XSLT itself.

The XSLT first checks if the Marketing plan asset has a property with a defined budget. It then checks if it inherits a budget from a related asset: a budget relation with the relation type ID "user.budget." with the property with the ID "censhare:budget.allocated" exists.

The example passes the information of the calculation as XML output: This contains the information if the check has been passed and adds the reason for the result.

<xsl:stylesheet version="2.0"
				xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 	
   				xmlns:xi="http://www.w3.org/2001/XInclude"
				xmlns:xs="http://www.w3.org/2001/XMLSchema"
				xmlns:my="http://www.censhare.com/my"
				exclude-result-prefixes="xi xs my"> 

<xsl:output method="xml" omit-xml-declaration="no" indent="no"/>

<!-- check if budget is defined at given asset or inherited from parent assets -->
<xsl:template match="asset">
 <xsl:variable name="ownBudget"
			   select="sum(asset_feature[@feature='censhare:budget']/@value_double)"/>
 <xsl:variable name="inheritedBudget"
			   select="sum(parent_asset_rel[@key='user.budget.']/asset_rel_feature[@feature= 	'censhare:budget.allocated']/@value_double)"/>

<check name="Check budget defined">
 <xsl:choose>
  <xsl:when test="$ownBudget=0 and $inheritedBudget=0">
   <item passed="false" reason="No budget defined or inherited"/>
  </xsl:when>
  <xsl:otherwise>
   <xsl:choose>
    <xsl:when test="$ownBudget=0">
     <item passed="true" reason="Budget inherited"/>
    </xsl:when>
    <xsl:otherwise>
     <item passed="true" reason="Budget defined"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:otherwise>
 </xsl:choose>
</check>
</xsl:template>
</xsl:stylesheet>
XML

You cannot use XPATH or XSLT at the same time. If an XPATH expression in the asset exists, the XSLT will be ignored.

Completeness check asset

Create asset

In censhare Web:

  • Click "Create asset" in the top-navigation bar.

  • In the "New asset" tab, select the "Completeness check" asset type.

  • Add a name and a resource key.

  • Click OK.

  • Open the new asset in an asset page.

  • Check "Enabled" in the Resource widget on the Overview tab.

  • Edit common properties as needed.

Add localizations and instruction text

  • Click the "Edit properties" button of the "General" widget.

  • For a localized name, enter the name in the "Name (localized)" field and select the language in the field behind it. The name is shown as the task name.

  • Click the Plus icon below the "Name (localized)" field to add another entry for a localized name.

  • In the "Description" field enter the instruction text for the completeness check. If there is no localized description for the actual user interface language, censhare shows this text.

  • For a localized description, enter the instruction text in the "Description (localized)" field and select the language in the field behind it.

  • Click the Plus icon below the " Description (localized)" field to add another entry for a localized description text.

Set filters

  • Click "Edit properties" in the Properties widget.

  • Enter the ID of desired asset type to filter in the "Asset type filter" field. For an overview about all IDs, see the "Asset types" table in the Masterdata section of the censhare Admin Client.

  • Enter the ID of the desired MIME type in the "MIME type filter" field if needed. For an overview about all IDs, see the "MIME types" table in the Masterdata section of the censhare Admin Client.

  • To add a MIME type filter, click the Plus icon below the "MIME type filter" field.

  • To add an asset type filter, click the Plus icon below the "Asset type filter" field.

  • To add an advanced filter, add an XPATH expression in the "Asset filter (XPath)" field.

  • To add further XPATH filters, click the Plus icon below the "Asset filter (XPath) field.

If you do not set at least one filter, the completeness check will be executed for all asset types in the censhare system.

Add XPATH check condition

  • Click "Edit properties" in the Properties widget.

  • Enter your XPATH expression in the "Expression (XPath)" field.

  • In the "Importance" field select "Required" or "Optional".

Add XSLT check condition

  • Prepare the text file with your XSLT script.

  • Drag your file on the Files widget or click the FILE button of the Files widget to select your file.

  • Click "Edit properties" in the Properties widget.

  • In the "Importance" field select "Required" or "Optional".

Result

You created the Completeness check assets. You added the respective filters to define the assets where completeness checks will be executed. You added the conditions to your completeness checks.

Next steps

If you want to work with a list of completeness checks for the desired assets, there are no further steps necessary.

If you want to define a sequence of quality states to be reach, define a Quality gate asset for each step and assign them in the desired sequence to a "Quality gate sequence" asset. Then assign the Completeness check assets, you have created, to the respective Quality gate assets.