Author |
Message
|
KIT_INC |
Posted: Tue Mar 22, 2011 6:51 am Post subject: How to re-use global element? |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
I am runnign WMB V61
I have created a global elemet with a name MY_GE. I want to use it multiple times in my message. I created a TDS message definition with many fileds (F1....Fn)
MY_MSG
F1 - simple type string
F2 - simple type date
F3 is Global element referecne to MY_GE
F4 - simple type
F5 - complex Type
:
F11 is Global element referecne to MY_GE
F12 - simple type
F13- complex Type
:
:
F31 is Global element referecne to MY_GE
:
Fn
I can parse the incoming message properly with the defintion
The message tree look like
MY_MSG
F1
F2
MY_GE
F4
F5
:
MY_GE
F12
F13
:
:
MY_GE
:
Fn
I have no rpoblem accessing the fields F3 by InputRoot.MRM.MY_MSG.F3
But how can I access the field MY_GE since there are more than 1 in the tree.
I am new to this. Did I misunderstand the use of global element and built the message definition wrong? I can not find any way to name the global element when I include it as part of my message. Can anyone help? |
|
Back to top |
|
 |
MrSmith |
Posted: Tue Mar 22, 2011 9:06 am Post subject: |
|
|
 Master
Joined: 20 Mar 2008 Posts: 215
|
Your global reference is not incorrect as there is nothing wrong with defining such an element and using it multiple times in the message set.
What do you want to retrieve from this MY_GE element just its positional value within the message i.e its index within the sperated fields? |
|
Back to top |
|
 |
KIT_INC |
Posted: Tue Mar 22, 2011 10:34 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
I need the value of the field. For example
DECLARE DATA CHAR;
SET DATA = InputRoot.MRM.MY_MSG.MY_GE;
I have tested it, I will have the DATA = the value of the first MY_GE. (MY_GE under F2 in the tree)
What if I want DATA to be set to the 31st (F31) MY_GE down the tree
I know that I can navigate down the tree (by index or simply by moving) to get to the MY_GE field that I want. That seems tedious. It will be nice if I can use correlation name followed by Path Elements to access MY_GE. But I do not know how to (or if I can) give it a name. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Mar 22, 2011 2:24 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I think you would have the same problem whatever language/technology you choose. The problem is that your logical model ( i.e. your schema ) is either too ambiguous or too flat. I can think of two ways to change it - I don't know which way is best because I don't know anything about your data model.
1. Use different global elements ( so the names will be different ). You can still achieve reuse by using the same simple type/complex type for all of the MY_GE1, MYGE2 global elements.
2. If each MY_GE element is really acting as the header for a group of elements then move all elements in the group ( including MY_GE ) under a new complex element. Then the path to each MY_GE will be different. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Mar 22, 2011 5:16 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Do you really need a global element?
Or do you just want to reuse the specifics of an element definition, that then applies to different elements at different locations with different names?
If the later, you just need a global simple type. |
|
Back to top |
|
 |
KIT_INC |
Posted: Wed Mar 23, 2011 6:11 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
Thanks for all the answers.
Hi mqjeff, I think I just want to reuse the specifics of an element definition.
Here is my scenario and what I did
For example my message has 5 fields
I created a complex type call NEW_MSG_TYPE as follow
NEW_MSG_TYPE
F1 xsd:string
F2 xsd:string
F3 xsd:string
F4 xsd:string
F5 xsd:string
Then I add a message called MY_NEW_MSG with Type = NEW_MSG_TYPE
MY_NEW_MSG NEW_MSG_TYPE
F1 xsd:string
F2 xsd:string
F3 xsd:string
F4 xsd:string
F5 xsd:string
Then I need to configure the phsical representaion of each field (F1 to F5) one by one.
In my case F2 to F5 has the same physical representation. Doing it this way, I have to repeat the configuration 4 times. What if I have many more fields to do.
I was hoping that using a local (or global) element I can only do the configuration once and re-sue it. But I run into the situation as described that I cannot navigate to the fields by simply using the field name. There must be a better way to do this.
You mentioned about 'global simple type'. Please correct me if I am wrong. I don't think I can configure physical representation when I create a simple type (list, restriction, or union).
I am also confuse that local/global object is mentioned in the manual (or info center, but the toolkit does not always have local or global objects.
For example, I am looking at Type under outline. If I right click , I can add simple or complex type. But nothing about local or global.
Under element, I can add global element or attribute but not local ? |
|
Back to top |
|
 |
kimbert |
Posted: Wed Mar 23, 2011 7:30 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
You mentioned about 'global simple type'. Please correct me if I am wrong. I don't think I can configure physical representation when I create a simple type (list, restriction, or union). |
You're right. This page in the infocenter proves it: http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ad06770_.htm
In the Outline view, the top-level objects are all global, so if you create a new one from there it will implicitly be global.
I can't think of a good solution to your problem yet...although you haven't said exactly which representation properties you want to set. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Mar 23, 2011 8:02 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Okay, there is a slightly different way to accomplish what you want.
construct the first element.
Select it, copy and paste to create a new element and give it a new name. |
|
Back to top |
|
 |
KIT_INC |
Posted: Wed Mar 23, 2011 9:07 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
Hi mqjeff, the copy, paste and rename sounds a little better than having to do it as many times as the number of fields. I just tried it. Unfortunately the physical representation does not get copied over. The new element created by paste contains the default physical representation and not the value from the original element. I am on CSD5. Not sure if this is a bug or the way it is. |
|
Back to top |
|
 |
KIT_INC |
Posted: Wed Mar 23, 2011 9:16 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
Hi kimbert, Thanks for pointing to the right page on info center. I am just trying to learn more about message modeling. So I do not have any specifc message that I want to model. But I think my scenario is not very unusal. Let's just pick a physical represntation of text field length of 5 byes and right justify. If my message has 50 filelds that need the same representation, I hope that I do not have to do it 50 times. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Mar 23, 2011 10:30 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
KIT_INC wrote: |
Hi kimbert, Thanks for pointing to the right page on info center. I am just trying to learn more about message modeling. So I do not have any specifc message that I want to model. But I think my scenario is not very unusal. Let's just pick a physical represntation of text field length of 5 byes and right justify. If my message has 50 filelds that need the same representation, I hope that I do not have to do it 50 times. |
My understanding is that you would set it a type and reuse this type 50 times.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
KIT_INC |
Posted: Wed Mar 23, 2011 10:44 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
Hi fjb_saper, but a type does not contain physical representation I need. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Mar 23, 2011 5:07 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
KIT_INC wrote: |
Hi fjb_saper, but a type does not contain physical representation I need. |
I thought the global element/ message derived from that type does contain the physical representation. Now if you create 50 elements and reference that message for each? Or make it repeatable like in occurs depending on?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|