Author |
Message
|
wbintegrator |
Posted: Wed May 06, 2015 12:57 am Post subject: XML recurring Sequence vs multiple instances of ComplexType |
|
|
Voyager
Joined: 08 Feb 2006 Posts: 83
|
Hi everybody.
We have a system that requires to receive an XML that contains the data in the form of Recurring sequences (I guess its called multi-instance sequence)
The desired result (OutpurRoot.MRM) is:
Code: |
<message>
<A>seq 1</A>
<B>1</B>
<C>2</C>
<A>seq 2</A>
<B>11</B>
<C>22</C>
.
.
</message>
|
while the incoming message is of the form:
Code: |
<message>
<A>inst 1</A>
<B>1</B>
<C>2</C>
<message>
<message>
<A>inst 2</A>
<B>11</B>
<C>22</C>
</message>
|
Any idea how to create that sequence structure with WMB?
I am trying to do the mapping in ESQL, and have failed to achieve
the sequence structure even though the mxsd is defined correctly.
Mapping to message[i].A creates instances of message
and message.A[i] fails with indexing error.
Any ideas how that can be achieved in ESQL?
Thanks! |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed May 06, 2015 1:14 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Quote: |
The desired result (OutpurRoot.MRM) is:
|
The MRM XML Parser was deprecated a long time ago. Are you using V2.1 still?
You should be using the XMLNSC parser.
What does your ESQL look like? _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
wbintegrator |
Posted: Wed May 06, 2015 3:05 am Post subject: |
|
|
Voyager
Joined: 08 Feb 2006 Posts: 83
|
smdavies99 wrote: |
Quote: |
The desired result (OutpurRoot.MRM) is:
|
The MRM XML Parser was deprecated a long time ago. Are you using V2.1 still?
You should be using the XMLNSC parser.
What does your ESQL look like? |
Yeah, I know - our infrastructure was written quite a while ago and we sticked to it so far. We are doing massive changes towards IIB9.
Currently we are on WMB7 mostly with MRM XML., utilizing XMLNSC
where possible or mandatory.
Anyway, my esql currently looks like this:
Code: |
DECLARE refIn REFERENCE TO InputRoot.XMLNSC.ns1:inMessage;
DECLARE i int 1;
FOR fbRow AS refIn.ns1:rows[] DO
SET OutputRoot.XMLNSC.message.A[i] = fbRow.ns1:Aid;
SET OutputRoot.XMLNSC.message.B[i] = fbRow.ns1:ActionDate;
SET OutputRoot.XMLNSC.message.C[i] = fbRow.ns1:Recipientid;
SET i = i + 1;
END FOR;
|
which also fails to achieve the desired result
Thanks for the reply! |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed May 06, 2015 5:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You need to have something like...
Code: |
FOR fbRow AS refIn.ns1:rows[] DO
CREATE LASTCHILD OF OutputRoot.XMLNSC.message NAME 'A' VALUE fbRow.ns1:Aid;
CREATE LASTCHILD OF OutputRoot.XMLNSC.message NAME 'B' VALUE fbRow.ns1:ActionDate;
CREATE LASTCHILD OF OutputRoot.XMLNSC.message NAME 'C' VALUE fbRow.ns1:Recipientid;
SET i = i + 1;
END FOR; |
And replace OutputRoot.XMLNSC.message with a reference...
Think about it and have fun  _________________ MQ & Broker admin
Last edited by fjb_saper on Wed May 06, 2015 5:05 am; edited 2 times in total |
|
Back to top |
|
 |
mqjeff |
Posted: Wed May 06, 2015 5:03 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
wbintegrator wrote: |
which also fails to achieve the desired result |
What does the result look like? |
|
Back to top |
|
 |
wbintegrator |
Posted: Wed May 06, 2015 6:15 am Post subject: |
|
|
Voyager
Joined: 08 Feb 2006 Posts: 83
|
mqjeff wrote: |
wbintegrator wrote: |
which also fails to achieve the desired result |
What does the result look like? |
An Exception LOL: Array subscript error (same as with MRM domain)
Guess what fjb_saper suggest must be one of the correct ways to achieve the result - but it makes me wonder, how come a structure inherently supported by XSD is not more straightward to achieve in ESQL.
The syntax that fails with the array error seems to be very intuitive and I was pretty sure I had used it before. but, well... My memory could be failing me as well
Thanks guys, I will think about what fjb_saper suggested and have some fun with it  |
|
Back to top |
|
 |
joebuckeye |
Posted: Wed May 06, 2015 6:37 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
Don't use array syntax, use references instead. FOR loops make this trivial as fjb_saper showed.
This method also performs better. |
|
Back to top |
|
 |
wbintegrator |
Posted: Wed May 06, 2015 6:51 am Post subject: |
|
|
Voyager
Joined: 08 Feb 2006 Posts: 83
|
joebuckeye wrote: |
Don't use array syntax, use references instead. FOR loops make this trivial as fjb_saper showed.
This method also performs better. |
Yeah, that's what I did and it does the work perfectly, thanks fjb_saper and everyone!
I'm still perplexed at the idea of having to manually create the structure instead of utilizing the messsageset to generate the desired structure more elegantly.
It seems to me something like creating delimiters by manually concatenating them instead of defining the delimiter and rendering the message in TDS format.
BizTalk 2005 that we are migrating from this specific code, does this sort of structural manipulations based solely on the xsd definition, without manual interference.
Sort of weird
Anyway, thanks again and great day! |
|
Back to top |
|
 |
inMo |
Posted: Wed May 06, 2015 12:25 pm Post subject: |
|
|
 Master
Joined: 27 Jun 2009 Posts: 216 Location: NY
|
Just curious - Is there really a difference in terms of 'elegance' between what you were willing to write:
Code: |
FOR fbRow AS refIn.ns1:rows[] DO
SET OutputRoot.XMLNSC.message.A[i] = fbRow.ns1:Aid;
SET OutputRoot.XMLNSC.message.B[i] = fbRow.ns1:ActionDate;
SET OutputRoot.XMLNSC.message.C[i] = fbRow.ns1:Recipientid;
SET i = i + 1;
END FOR;
|
and what this thread ended up producing:
Code: |
FOR fbRow AS refIn.ns1:rows[] DO
CREATE LASTCHILD OF OutputRoot.XMLNSC.message NAME 'A' VALUE fbRow.ns1:Aid;
CREATE LASTCHILD OF OutputRoot.XMLNSC.message NAME 'B' VALUE fbRow.ns1:ActionDate;
CREATE LASTCHILD OF OutputRoot.XMLNSC.message NAME 'C' VALUE fbRow.ns1:Recipientid;
SET i = i + 1;
END FOR;
|
I ask as an academic exercise to understand what else could occur that would qualify as simpler or more elegant? What did the other tool do in this scenario? |
|
Back to top |
|
 |
maurito |
Posted: Wed May 06, 2015 11:51 pm Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
inMo wrote: |
I ask as an academic exercise to understand what else could occur that would qualify as simpler or more elegant? What did the other tool do in this scenario? |
more elegant and efficient would be a nested select from the input message, which, by the way is incorrect as it has 2 level 1 tags, it should be something like
Code: |
<test>
<message>
<A>inst 1</A>
<B>1</B>
<C>2</C>
<message>
<message>
<A>inst 2</A>
<B>11</B>
<C>22</C>
</message>
</test> |
|
|
Back to top |
|
 |
kimbert |
Posted: Sat May 09, 2015 2:21 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
more elegant and efficient would be a nested select from the input message |
I agree. The SELECT statement would do the task in one ESQL statement. Whether that would be easier to read and maintain is a matter of opinion, of course. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
inMo |
Posted: Mon May 11, 2015 6:10 am Post subject: |
|
|
 Master
Joined: 27 Jun 2009 Posts: 216 Location: NY
|
Any documentation links on performing selects against XML structures? Or an example of one that would work against the structure in this thread? |
|
Back to top |
|
 |
maurito |
Posted: Mon May 11, 2015 6:47 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
inMo wrote: |
Any documentation links on performing selects against XML structures? Or an example of one that would work against the structure in this thread? |
search for 'Transforming a complex message' in the documentation |
|
Back to top |
|
 |
|