CompanionCompanion
Companion for Delivery
Companion for Business
Companion for Integration
Contact us
Log out
Companion for Delivery
Companion for Business
Companion for Integration
Contact us
  • Companion for Integration

    • Introduction
    • Getting Started
    • Configuration
    • Excel templating
    • How it works
  • YAML Configuration

    • Principles
    • Syntax
    • Validation
  • Custom Functions

    • Summary
    • arrayToJSON
    • bool
    • concatValueAndUnit
    • convertUnit
    • currentContextId
    • exportTime
    • eval
    • firstNonEmpty
    • getContextName
    • getEvents
    • getLastEventTime
    • getReferencesByAttributeGroup
    • getStoredValue
    • getWorkspaceId
    • hash
    • hasStoreKey
    • if
    • integer
    • join
    • mergeInheritedValues
    • multiValuesToJSON
    • number
    • nodeList
    • order
    • resolveUnitLabel
    • serializeAssetPushLocationsToJSON
    • serializeAttributeLinksToJSON
    • serializeContextReferenceToJSON
    • serializeContextReferencesToJSON
    • serializeContextValuesToJSON
    • serializeDataContainerToJSON
    • serializeDataContainersToJSON
    • serializeListOfValueValuesToJSON
    • serializeReferencesToJSON
    • serializeReferenceToJSON
    • serializeValuesToJSON
    • store
    • toXML
    • uppercase
  • Execution

    • Summary
    • Composite
    • From STEP
    • Standalone
    • Performance statistics
  • Configuration

    • ActiveMQ extension
    • Amazon AWS extension (SNS, SQS, Kinesis, S3)
    • ElasticSearch/OpenSearch extension
    • File extension (Excel, CSV, JSON, XML, JSONL, XMLL)
    • Kafka extension
    • Kafka Core extension
    • MongoDB/Cosmos DB extension
    • SQL extension
    • REST extension
    • Google Pub/Sub extension
  • c4i SaaS

    • Introduction
    • Managing jobs
    • Managing executions
    • Managing users
    • Changelog
  • Changelog

    • Core features changelog
    • ActiveMQ extension changelog
    • Amazon AWS extension changelog
    • Composite extension changelog
    • ElasticSearch extension changelog
    • File extension changelog
    • Kafka extension changelog
    • Kafka Core extension changelog
    • MongoDB/Cosmos DB extension changelog
    • SQL extension changelog
    • REST extension changelog
    • Google Pub/Sub extension changelog

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: 12/5/24, 1:39 PM
Prev
join
Next
multiValuesToJSON