mergeInheritedValues

The mergeInheritedValues function is used to merge values from a child node with the values from its parent. Only works for single-context values, such as returned by the serializeValuesToJSON function

Syntax

c4i:mergeInheritedValues(parentValues, childValues)

Parameters

parentValues

The values from the parent node, usually returned by the serializeValuesToJSON function

separator

The values from the child node, usually returned by the serializeValuesToJSON function

Return value

A JSON document containing the values from the parent and the child node.

Examples

Given the following STEP XML:

<STEP-ProductInformation>
    <AttributeList>
        <Attribute ID="ATT1">
            <Validation BaseType="text"/>
        </Attribute>
        <Attribute ID="ATT2">
            <Validation BaseType="number"/>
        </Attribute>
    </AttributeList>
    <Products>
        <Product ID="FAM1" UserTypeID="FAM">
            <Values>
                <Value AttributeID="ATT1">Test</Value>
                <Value AttributeID="ATT2">16</Value>
            </Values>
        </Product>
        <Product ID="PRD1" UserTypeID="PRD" ParentID="FAM1">
            <Values>
                <Value AttributeID="ATT2">18</Value>
            </Values>
        </Product>
    </Products>
</STEP-ProductInformation>

The following YAML configuration will produce the following output

- Product[@UserTypeID="FAM"]:
    - .families[id]:
      - ./@ID: id
      - c4i:store(string(@ID), c4i:serializeValuesToJSON(Values)): values

- Product[@UserTypeID="PRD"]:
    - products[id]:
      - ./@ID: id
      - c4i:mergeInheritedValues(c4i:getStoredValue(string(@ParentID)), c4i:serializeValuesToJSON(Values)): values
{
  "ATT1": "Test",
  "ATT2": 18
}
Last Updated: