| Author | Message | 
		
		  | adkessell | 
			  
				|  Posted: Tue May 06, 2003 4:55 pm Post subject: Transforming XML to MRM with optional elements |   |  | 
		
		  | Novice
 
 
 Joined: 29 Aug 2001Posts: 10
 
 
 | 
			  
				| I have a XML message that has elements that are optional, and I want to transform the XML to a MRM structure. 
 Is there a simple way to make elements optional in MRM using the CWF? So that the option elements in the XML can be left out of the MRM structure on outbound.
 
 XML  (B is Optional)
 <Msg><A>ccc</A><B>vvvv</B><C>zzzzz</C></Msg>
 
 MRM
 A1 = A
 B1 = B (Optional)
 C1 = C
 
 So if B is missing from the XML I want B1 not to show up in the output MRM message.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kirani | 
			  
				|  Posted: Tue May 06, 2003 8:38 pm Post subject: |   |  | 
		
		  | Jedi Knight
 
 
 Joined: 05 Sep 2001Posts: 3779
 Location: Torrance, CA, USA
 
 | 
			  
				| As per Working With Messages manual ... 
 
   
	| Quote: |  
	| When you have created the basic structure of a message using the Control Center, you must consider what level of complexity needs to be added to the model:
 . Can an element repeat? Is so how many times can it repeat? The default is that an element does not repeat, that is, there is one and only one instance.
 . Is an element optional or mandatory? The default is that an element is
 mandatory.
 
 You can modify these defaults for documentation purposes by updating the
 properties on the Connection pane for compound types and elements (see “Type” on page 49 and “Element” on page 45). However, these properties, and the conditions they define, are not enforced by the broker.
 
 |  
 You could define 2 different message formats, one with B1 and another without B1.
 _________________
 Kiran
 
 
 IBM Cert. Solution Designer & System Administrator - WBIMB V5
 IBM Cert. Solutions Expert - WMQI
 IBM Cert. Specialist - WMQI, MQSeries
 IBM Cert. Developer - MQSeries
 
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | adkessell | 
			  
				|  Posted: Wed May 07, 2003 3:32 am Post subject: |   |  | 
		
		  | Novice
 
 
 Joined: 29 Aug 2001Posts: 10
 
 
 | 
			  
				| Yes I have thought of that, but one thing I forgot to mention is that the XML and MRM message are a lot more complex. There is actually 12 elements that can be optional in a random way. 
 So there isn't a sit sequence that they will be there in which makes it hard to setup different MRMs to cover the different combinations that could arise.
 
 Thanks
 Anthony
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Miriam Kaestner | 
			  
				|  Posted: Wed May 07, 2003 10:28 am Post subject: |   |  | 
		
		  | Centurion
 
 
 Joined: 26 Jun 2001Posts: 103
 Location: IBM IT Education Services, Germany
 
 | 
			  
				| For CWF physical format (and TDS with fixed length), it is not possible to leave out any element. You may define an element as optional, but then you must define a default value for it. Otherwise the parser can't determine which element is actually missing. |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | lung | 
			  
				|  Posted: Wed May 07, 2003 11:23 pm Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 27 Aug 2002Posts: 291
 Location: Malaysia
 
 | 
			  
				| I don't get it. What does defining it to be 'optional' actually do, when it will still exist in the final output? |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | drajib | 
			  
				|  Posted: Thu May 08, 2003 4:29 am Post subject: |   |  | 
		
		  |  Apprentice
 
 
 Joined: 25 Mar 2003Posts: 42
 Location: India
 
 | 
			  
				| For a Tag Delimited Variable Length message, I have been able to make the fields optional (Min Occurs in Connection tab = 0). However I could not solve the following so far 
 Message Structure
 
 
   
	| Quote: |  
	| MSG (Tag Delimited Variable Length - <LF>) - HDR (Mandatory 1-1, Delimiter - <LF>)
 - DTL (Optional 0-n, Repeating element delimiter - <LF>)
 - FTR (Mandatory 1-1, Delimiter - <LF>)
 
 |  
 The output data is coming out as
 
 
   
	| Quote: |  
	| Fields for HDR <LF> <LF>
 Fields for FTR <LF>
 
 |  
 Could you please throw some light on how to make it
 
 
   
	| Quote: |  
	| Fields for HDR <LF> Fields for FTR <LF>
 
 |  i.e. The Repeating element delimiter for DTL should not be present.
 
 Best regards,
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | lung | 
			  
				|  Posted: Mon Jan 16, 2012 7:13 pm Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 27 Aug 2002Posts: 291
 Location: Malaysia
 
 | 
			  
				| Hi, 
 Any workaround for the problem above?
 I found myself trying to achieve the same thing.
 
 Am actually looking at CWF with Min Occurs = 0, and Max Occurs = 1, but the Min Occurs doesn't seem to actually do anything, as when I don't map anything, it will still appear as the default values with the assigned length.
 
 How do I make the field to totally disappear without resorting to TDS?
 
 Thanks!
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Mon Jan 16, 2012 8:42 pm Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| 
   
	| lung wrote: |  
	| Hi, 
 Any workaround for the problem above?
 I found myself trying to achieve the same thing.
 
 Am actually looking at CWF with Min Occurs = 0, and Max Occurs = 1, but the Min Occurs doesn't seem to actually do anything, as when I don't map anything, it will still appear as the default values with the assigned length.
 
 How do I make the field to totally disappear without resorting to TDS?
 
 Thanks!
 |  
 Look at how the COBOL occurs depending on is modeled...
  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | lung | 
			  
				|  Posted: Mon Jan 16, 2012 10:15 pm Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 27 Aug 2002Posts: 291
 Location: Malaysia
 
 | 
			  
				| Yea, I am trying to get the actual copybook from the receiving program, but until then I need to figure this out on my own... 
 Basically, input data is something like:
 <XML>
 <A>ABC</A>
 <B></B>
 <C>GHI</C>
 </XML>
 
 Assuming all fields are 3 bytes, in CWF, I need to make this as:
 ABCGHI
 
 Instead of:
 ABC   GHI
 
 I need WMB to automatically make field B occurs = 0 when there is zero length and/or no mapping involved...
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kimbert | 
			  
				|  Posted: Tue Jan 17, 2012 2:57 am Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 29 Jul 2003Posts: 5543
 Location: Southampton
 
 | 
			  
				| 
  Why do you want to avoid TDS? If CWF cannot do what you need, then you should use TDS. 
	| Quote: |  
	| How do I make the field to totally disappear without resorting to TDS? |  
 
  I assure you that it does a lot. The minOccurs setting is a property of the *logical* format. It describes what is in the message tree. There may be very good reasons why a field that is missing from the tree needs to appear in the data ( e.g. in order to make the data parseable by the downstream application ) 
	| Quote: |  
	| the Min Occurs doesn't seem to actually do anything, as when I don't map anything, it will still appear as the default values with the assigned length. |  I have no idea whether this applies in your case - you have given very little information about the physical layout of your data format. As a start, you could tell us whether this optional field is tagged.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | lung | 
			  
				|  Posted: Tue Jan 17, 2012 3:19 am Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 27 Aug 2002Posts: 291
 Location: Malaysia
 
 | 
			  
				| Hi, 
 The reason why I prefer to use CWF is because I want to keep track of the max length of the field, this has often come up as a troubleshooting issue in the past when I used TDS.
 
 As per my given example, that is the physical layout I require.
 There is no additional tagging on the optional field.
 
 Basically I have 3 fields (A, B, C), and assuming field B is optional, I need a way to dynamically set its min & max occurrence to 0 so that it will not appear in the message at all (not even with its default value).
 
 As per the previous example, what I need is:
 ABCGHI
 
 Instead of:
 ABC___GHI
 (Where _ = space, the default value)
 
 Hope this gets my question across clearer... Thanks!
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kimbert | 
			  
				|  Posted: Tue Jan 17, 2012 3:41 am Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 29 Jul 2003Posts: 5543
 Location: Southampton
 
 | 
			  
				| Your data format is very unusual - optional fields are almost always tagged or else there is a field that gives the number of occurrences. Please explain how the receiver will parse this message. Will they look at the length of the message? Or maybe B and C are easily distinguished because their 'lexical space' is completely different? 
 
  Your requirement is to be able to omit B from the output message. The solution is *not* to adjust minOccurs and maxOccurs - that is impossible anyway.  I suggest that you try setting  'Data Element Separation' to 'Use Data Pattern'. That will switch off the defaulting, anyway. 
	| Quote: |  
	| Basically I have 3 fields (A, B, C), and assuming field B is optional, I need a way to dynamically set its min & max occurrence to 0 so that it will not appear in the message at all (not even with its default value). |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Tue Jan 17, 2012 5:44 am Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| lung wrote: |  
	| As per the previous example, what I need is: ABCGHI
 
 Instead of:
 ABC___GHI
 (Where _ = space, the default value)
 
 |  
 How does the downstream application (which consumes this) determine that "GHI" in "ABCGHI" is the third element rather than the second?
  _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | lung | 
			  
				|  Posted: Tue Jan 17, 2012 5:47 pm Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 27 Aug 2002Posts: 291
 Location: Malaysia
 
 | 
			  
				| Hi, 
 It is actually delimited. I am omitting that info because what I want to do is to achieve this in CWF as mentioned earlier.
 
 So the output will actually be:
 ABC<LF><LF>GHI<LF>
 (where <LF> is the delimiter)
 
 I am actually defining the <LF> delimiters as additional fields.
 
 kimbert,
 
 This is actually related to the email I sent to you yesterday.
 
 I cannot use TDS because there is the problem where a fixed length complex type will always have an additional FD when followed right after with a variable length element.
 
 Is there a way to use TDS but in fixed length, and somehow tell WMB to omit optional fields from being generated?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | cociu_2012 | 
			  
				|  Posted: Wed Jan 18, 2012 12:19 am Post subject: Re: Transforming XML to MRM with optional elements |   |  | 
		
		  | Acolyte
 
 
 Joined: 06 Jan 2012Posts: 72
 
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |