Author |
Message
|
scravr |
Posted: Tue Jun 28, 2011 10:18 am Post subject: Broker 7: Remove empty XML elements |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
and HI to All
On Broker 7:
I am getting COBOL msg and need to gener XML.
COBOL have SPACES and ZEROS on input message.
Trying to "shrink" output msg size. How can I remove the empty elements on output XML?
Any setting on msg-set XML1 ?
Thanks,
Mos |
|
Back to top |
|
 |
lancelotlinc |
Posted: Tue Jun 28, 2011 10:23 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Why are you trying to shrink the output message size? Do you pay for bandwidth by the byte? How many cents per byte is it? Or, is it common cents? _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 28, 2011 10:29 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
There certainly are options to control whether an optional element is rendered and how null values are represented.
If you are going through a training class, you should identify this question to your instructor.
If you are going through self-study, you need to clearly indicate this, and then demonstrate that you are doing more to study this yourself than just posting questions here. |
|
Back to top |
|
 |
scravr |
Posted: Tue Jun 28, 2011 10:31 am Post subject: |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
dont u think its common cents?
Why would you send 1K+ bytes of empty xml tags 3M times a day every day? |
|
Back to top |
|
 |
scravr |
Posted: Tue Jun 28, 2011 11:38 am Post subject: |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
Here is the flow:
MQInput gets COBOL msg as BLOB, then ESQL compute node parse (into env. variable) based on msg-set build from COBOL COPYBOOK with Binary1 as MRM .
Then ESQL moves env. variable into OutputRoot.XMLNSC domain, and then to MQOutput.
In debug: before MQOutput step:
OutputRoot.Properties: pointing to 2nd msg-set build from XSD with XML1, and msg-type
OutputRoot.MQMD points to MQHRF2
OutputRoot.XMLNSC has all COBOL fields as XML elements. Empry elements are "UNKNOWN:null"
getting msg with rfhutil shows many empty elements like <FirstName></FirstName>
XML msg-set as "default msg domain" as XMLNSC. NO wire formats defined.
all elements on msg definition have "Value" as "Default" (empty). Nillable is not used. Min/Max occurs as 0/1.
Where is ESQL or output msg-set can I ask to remove empty elements? |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 28, 2011 11:53 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Create a new message flow.
This message flow will populate various fields in your output message with different types of 'empty' elements - like one has fieldvalue == null and one is '0000' and etc.
See what the output message looks like when it's rendered to XML.
Review the documentation on the XMLNSC parser to understand why it made the choices it did. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Jun 28, 2011 11:54 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
XML msg-set as "default msg domain" as XMLNSC. NO wire formats defined. |
Probably a good thing. XMLNSC never looks at the XML wire format ( btw, it's called 'physical format' since v5 )
The MRM parser is the only parser that looks at the wire/physical formats in the message set.
Quote: |
Where is ESQL or output msg-set can I ask to remove empty elements? |
You cannot do this with a message set, not even if you use the MRM parser ( but you would never use the MRM parser for XML anyway, right? ).
So you need to do it in ESQL or Java or Mapping node. That should be easy. Tell us what you tried, and describe what happened. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jun 28, 2011 11:57 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
scravr wrote: |
Where is ESQL or output msg-set can I ask to remove empty elements? |
You can't - if you don't want these elements write code to remove them.
There's a difference between an empty element, a null (or nill) element and a missing element.
These elements are in the output message because the COBOL message says they exist. Nothing you can configure changes this fact. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
scravr |
Posted: Tue Jun 28, 2011 12:08 pm Post subject: |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
we are on V7 and
u guys telling me "THERE IS NO WAY" to remove empty (not wanted) XML elements !!!
flow is generic to accept many types of COBOL and reformat to many XML.
I cannot write numerus mapping/esql/java code - 1 for each msg-type.
there must be an indication on xml msg-set to remove empty/null elements !!! |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jun 28, 2011 12:16 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
scravr wrote: |
there must be an indication on xml msg-set to remove empty/null elements !!! |
I keep telling my management there must be a way they can pay me more and they seem convinced there isn't.
There is a difference between an empty and a null element; both have meaning in an XML document and you can't (and shouldn't want to) have WMB arbitraially remove them.
Or to put it another way - if kimbert says you can't do this without code, you can't do this without code.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
scravr |
Posted: Tue Jun 28, 2011 12:21 pm Post subject: |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
Can msg-set with XML wire format and "encoding numeric Null" of NULLEmpty do it? |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 28, 2011 12:23 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
What happens when you try it? |
|
Back to top |
|
 |
scravr |
Posted: Tue Jun 28, 2011 12:38 pm Post subject: |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
|
Back to top |
|
 |
Vitor |
Posted: Tue Jun 28, 2011 12:39 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
scravr wrote: |
Can msg-set with XML wire format and "encoding numeric Null" of NULLEmpty do it? |
kimbert wrote: |
You cannot do this with a message set, not even if you use the MRM parser |
Note:
kimbert wrote: |
( but you would never use the MRM parser for XML anyway, right? ). |
_________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Jun 29, 2011 12:37 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Write some ESQL to walk the message tree recursively and delete empty elements. Let us know how it goes. |
|
Back to top |
|
 |
|