Navigating a non-navigable (one way) association [message #694498] |
Fri, 08 July 2011 17:54 |
|
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
|
|
|
|
|
|
Re: Navigating a non-navigable (one way) association [message #694562 is a reply to message #694554] |
Fri, 08 July 2011 20:46 |
|
Ahhh I get it.
Here is my new query:
context MultiBlock
block->select(blockDef.templateName='SYSTEM:CPM200').embBlocks.block.blockDef
Thank you for your help.
I am just new to this OCL thing and I have 10s of hours trying to figure out what is possible or not worth its time. Ed you helped me understand that what I was doing was possible with OCL so thank you.
-Mark
|
|
|
Powered by
FUDForum. Page generated in 0.04734 seconds