Hello,
I am currently trying to build up a dynamic information model. The aim is to read in an XML file with import() and map the data to the information model. There are elements in the XML file which can occur 0, 1 or unbounded times. I modelled them as Optional Placeholder. Now I want to dynamically decide based on the occurance of an element in the XML how many optional placeholders should be instantiated during the call of import().
How can I instantiate the Object2 in Code?
Object1 (ObjectyType1, Mandatory)
-Variable1 (Mandatory)
-Variable2 (Mandatory)
-Object2 (ObjectType2, Optional Placeholder)
--Variable3
--Variable4
--Object3(ObjectType3, OptionalPlaceholder)
...
I managed to instantiate Optionals dynamically with the setVariable(x)-method, but the Optional Placeholder instantiation seems to be more complicated.
Thank you very much in advance.
How to programmatically make use of the OptionalPlaceHolder
Moderator: uamodeler
-
- Full Member
- Posts: 8
- Joined: 01 Jun 2016, 08:22
- Support Team
- Hero Member
- Posts: 3071
- Joined: 18 Mar 2011, 15:09
Re: How to programmatically make use of the OptionalPlaceHol
Hello,
you need to create an instance of ObjectType2 and call addObject2().
Best Regards
Support Tam
you need to create an instance of ObjectType2 and call addObject2().
Code: Select all
NodeManager *pNM;
ObjectType1 *pObject1 = new ObjectType1(nodeId1, name1, nsIdx, pNM);
pNM->addNodeAndReference(parentNodeId, pObject1 , referenceTypeId)
ObjectType2 *pObject2 = new ObjectType2(nodeId,2 name2, nsIdx, pNM);
pObject1->addObject2(pObject2);
Best Regards
Support Tam