Expand my Community achievements bar.

SOLVED

Difference between aggregate and template for a schema element

Avatar

Employee

Within a schema element, we can define two attributes namely "aggregate" and "template" but both seem to serve the same purpose of copying another element's definition. What exactly is the difference between them and what situation do we use one over the other?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @HariharanB ,

 

aggregate: lets you copy the definition of an <element> via another schema. This attribute receives a schema declaration in the form of a “namespace:name”.
For example, there are many element in xtk:common schema. If we want to use only auditTrail element in your schema, you can use aggregate, like

 

<element aggregate="xtk:common:auditTrail" name="auditTrail"/>

 

 

 

xtk:common
<element name="auditTrail">
<element defOnDuplicate="true" name="createdBy" template="xtk:common:createdBy"/>
<element defOnDuplicate="true" name="modifiedBy" template="xtk:common:modifiedBy"/>
<attribute defOnDuplicate="true" default="GetDate()" desc="Creation date" label="Creation date"
name="created" type="datetime"/>
<attribute defOnDuplicate="true" default="GetDate()" desc="Modification date"
label="Last modified" name="lastModified" pkgStatus="always" type="datetime"/>
</element>

 

 

template: this attribute defines a reference to an <element> element shared by several schemas. The definition is automatically copied into the current schema.
For Example, You can check broadLogRcp schema, which use template nms:broadLog. This will take all elements, attributes, enumerations, links etc which are created in nms:broadLog and create the same in nms:broadLogRcp

 

<element name="broadLogRcp" template="nms:broadLog">

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @HariharanB ,

 

aggregate: lets you copy the definition of an <element> via another schema. This attribute receives a schema declaration in the form of a “namespace:name”.
For example, there are many element in xtk:common schema. If we want to use only auditTrail element in your schema, you can use aggregate, like

 

<element aggregate="xtk:common:auditTrail" name="auditTrail"/>

 

 

 

xtk:common
<element name="auditTrail">
<element defOnDuplicate="true" name="createdBy" template="xtk:common:createdBy"/>
<element defOnDuplicate="true" name="modifiedBy" template="xtk:common:modifiedBy"/>
<attribute defOnDuplicate="true" default="GetDate()" desc="Creation date" label="Creation date"
name="created" type="datetime"/>
<attribute defOnDuplicate="true" default="GetDate()" desc="Modification date"
label="Last modified" name="lastModified" pkgStatus="always" type="datetime"/>
</element>

 

 

template: this attribute defines a reference to an <element> element shared by several schemas. The definition is automatically copied into the current schema.
For Example, You can check broadLogRcp schema, which use template nms:broadLog. This will take all elements, attributes, enumerations, links etc which are created in nms:broadLog and create the same in nms:broadLogRcp

 

<element name="broadLogRcp" template="nms:broadLog">