Author |
Message
|
PEPERO |
Posted: Tue Sep 04, 2012 9:13 pm Post subject: evaluateXpath duplicate outputs |
|
|
Disciple
Joined: 30 May 2011 Posts: 177
|
Hi;
I'm using the evaluateXpath expression to retrive the incomming message from a webservice which has the following XMLNSC tree structure.
(0x01000000:Folder):XMLNSC = ( ['xmlnsc' : 0x915fb9110]
(0x01000000:Folder)http://datamodel:msg_IV00OUTPUT = ( ['xmlnsc' : 0x915fb9110]
(0x03000102:NamespaceDecl ):xmlns = 'http://datamodel'
(0x03000070:PCDataField+List):msg_Len = NULL
(
(0x03000102:NamespaceDecl):xmlns = '' (CHARACTER)
(0x02000000:PCDataValue ): = X'00000002' (BLOB)
)
(0x03000070:PCDataField+List):ALERT_CODE = NULL
(
(0x03000102:NamespaceDecl):xmlns = '' (CHARACTER)
(0x02000000:PCDataValue ): = '02' (CHARACTER)
)
)
)
When retriving the incomming message using evaluateXpath("string(//)") it duplicates the node values so an output of the form "00000006000000060202" would be generated.
Does anybody have any idea to resolve this problem?
<msg_IV00OUTPUT>
<msg_Len>X'00000002'</msg_Len>
<ALERT_CODE>02</ALERT_CODE>
</msg_IV00OUTPUT>
the data type of the msg_Len is 4 byte hexBinary.
Last edited by PEPERO on Wed Sep 05, 2012 3:42 am; edited 1 time in total |
|
Back to top |
|
 |
PEPERO |
Posted: Tue Sep 04, 2012 9:30 pm Post subject: |
|
|
Disciple
Joined: 30 May 2011 Posts: 177
|
I'm sorry. The output is 00000002000000020202. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Sep 04, 2012 10:22 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Version and fix pack as well as effective level of the broker?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
PEPERO |
Posted: Wed Sep 05, 2012 12:19 am Post subject: |
|
|
Disciple
Joined: 30 May 2011 Posts: 177
|
the version of the Message broker is V7 and the effective level is 7.0.0.1. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 05, 2012 12:27 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
When retriving the incomming message using evaluateXpath("string(//)") it duplicates the node values |
That's a strange-looking XPath expression. What exactly are you trying to do?
Quote: |
a webservice which has the following XMLNSC tree structure. |
Please use the [Edit] button and add [c o d e] tags around the quoted data. It makes it much easier to read. |
|
Back to top |
|
 |
PEPERO |
Posted: Wed Sep 05, 2012 3:29 am Post subject: |
|
|
Disciple
Joined: 30 May 2011 Posts: 177
|
I want to extract the node values to make a BLOB message. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Sep 05, 2012 3:57 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I would use a new message model that was TDS to handle this, and then map the XML message to the TDS model and serialize it.
Otherwise, yes, you appear to have run into the fact that xpath returns ALL matching results. |
|
Back to top |
|
 |
mqsiuser |
Posted: Wed Sep 05, 2012 4:41 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
mqjeff wrote: |
Otherwise, yes, you appear to have run into the fact that xpath returns ALL matching results. |
xpath returns a node set. It returns all matching nodes.
I would assign it to a Java "List" before proceeding:
Code: |
List nodeSet = (List) message.getRootElement().evaluateXPath("//NameOfElementsThatIWant"); |
|
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 05, 2012 4:46 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I cannot explain the duplication of the values. Maybe you did not post the entire message tree?
Quote: |
the data type of the msg_Len is 4 byte hexBinary. |
It sounds as if the output contains some non-character data. If so, XPath is the wrong solution. It's probably the wrong solution anyway. The standard solution for transforming XML to BLOB is
v7 : use the MRM parser with a message set and a TDS physical format
v8 : use the DFDL parser |
|
Back to top |
|
 |
PEPERO |
Posted: Wed Sep 05, 2012 9:28 am Post subject: |
|
|
Disciple
Joined: 30 May 2011 Posts: 177
|
Thanks all. I'll use the MRM solution. |
|
Back to top |
|
 |
PEPERO |
Posted: Wed Sep 05, 2012 11:18 pm Post subject: |
|
|
Disciple
Joined: 30 May 2011 Posts: 177
|
So how could i generate the MRM message tree having the XMLNSC one with the minimum impact. I mean shall i copy element by element of the XMLNSC message tree to the new MRM one or there is a better way. |
|
Back to top |
|
 |
mqsiuser |
Posted: Wed Sep 05, 2012 11:42 pm Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
PEPERO wrote: |
I mean shall i copy element by element of the XMLNSC message tree to the new MRM one |
yes
PEPERO wrote: |
or there is a better way. |
no (especially do not try and use xPath for that)... probably you can do a ESQL-SELECT... but... I would:
In:
Code: |
<msg_IV00OUTPUT>
--<msg_Len>X'00000002'</msg_Len>
--<ALERT_CODE>02</ALERT_CODE>
</msg_IV00OUTPUT> |
Out:
Code: |
00000002000000020202 |
Probably you just use OutputRoot.BLOB. Something like:
Code: |
SET OutputRoot.BLOB = CAST( inRef.msg_Len || inRef.msg_Len || inRef.ALERT_CODE || inRef.ALERT_CODE AS BLOB); |
With MRM you have to assign 4 Fields (in ESQL) and create a msg set |
|
Back to top |
|
 |
kimbert |
Posted: Thu Sep 06, 2012 5:18 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I mean shall i copy element by element of the XMLNSC message tree to the new MRM one |
No. You should be able to just copy the entire message tree in one line of ESQL. Like this:
Code: |
SET OutputRoot.XMLNSC.rootElementName = InputRoot.MRM; |
The InputRoot.MRM does not contain the root element, so you will need to replace 'rootElementName' with the appropriate name. It is usually available in InputRoot.Properties.MessageType', but in your flow it will probably be OK to hard-code the name. |
|
Back to top |
|
 |
PEPERO |
Posted: Thu Sep 06, 2012 8:11 am Post subject: |
|
|
Disciple
Joined: 30 May 2011 Posts: 177
|
thanks so much for your valuable guidlines. |
|
Back to top |
|
 |
|