I have the following XML model:
MultiBlock
Block
BlockDef
Parameters
Parameter
EmbBlocks
Block
BlockDef
Block
BlockDef
Block must contain BlockDef
Block can contain EmbBlocks
EmbBlocks can contain Block
I want to select all the Block objects contained in the EmbBlock object if the top level BlockDef has certain values.
I was trying
context MultiBlock
block.embBlocks->excluding(null).block->select(this.block.blockDef.templateName='SYSTEM:CPM200')
but this fails.
Evaluating:
block.embBlocks->excluding(null).block->select(this.block.blockDef.templateName='SYSTEM:CPM200')
Results:
Parsing failure
null
Unresolved property 'block' for 'unknown-type'
Unresolved property 'embBlocks' for 'OclInvalid'
Unresolved property 'block' for 'Set<OclInvalid>'
Unresolved property 'this' for 'Bag<OclInvalid>'
Unresolved property 'block' for 'OclInvalid'
Unresolved property 'blockDef' for 'OclInvalid'
Unresolved property 'templateName' for 'OclInvalid'
Unresolved property 'block' for 'Bag<OclInvalid>'
Because the model is XML it does not contain opposite navigations
IE, I can't navigate from BlockDef up to its container Block.
Does OCL have the capability to select objects based on a condition that must be computed from on a non-navigable (one way) association? How do I reference back to the starting context?
I was thinking:
context MultiBlock
block.embBlocks->excluding(null).block->select(<<embBlocks_opposite>>.<<block_opposite>>.block.blockDef.templateName='SYSTEM:CPM200')
what would be a query that works?
This query is going to feed a QVTO transform.
Thank you,
-Mark