Author |
Message
|
sirisha.n |
Posted: Thu Aug 21, 2008 4:19 am Post subject: Problem in checking no of occurences with 'MRM' domain |
|
|
Apprentice
Joined: 25 Feb 2008 Posts: 27
|
Hi,
I need to check the no of occurences of a child element in the xml message. i have tried with cardianlity function. i can able to retrive the no of occurences successfully.
DECLARE ItemNumCounter INTEGER;
ItemNumCounter=CARDINALITY(InputRoot.XML.N_PRIface.Content.N_PR.PR.PRLINE[]);
But, if the input message type is of 'MRM' , its giving warning and unable to deploy.
please suggest, is there any other way to check the no of occurences with 'MRM' domain.
 |
|
Back to top |
|
 |
sridhsri |
Posted: Thu Aug 21, 2008 5:21 am Post subject: |
|
|
Master
Joined: 19 Jun 2008 Posts: 297
|
cardinality should work with MRM too. I guess you are just replacing XMl with MRM. That might not work. While using the XML parser, you need to specify the Root element (Ex: OutputRoot.XML.RootElement.Element). But when using MRM you don't (Ex: OutputRoot.MRM.Element). Perhaps that explain why you didn't get the results you expected. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Aug 21, 2008 5:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I need to check the no of occurences of a child element in the xml message |
If you are trying to validate your XML, you should be using a message set, and enabling validation in your message flow. And you should be using XMLNSC, not the ( deprecated ) XML domain.
If you are trying to write a loop which processes each occurrence of PRLINE then you should be using references, not a loop counter. |
|
Back to top |
|
 |
paranoid221 |
Posted: Thu Aug 21, 2008 2:50 pm Post subject: |
|
|
 Centurion
Joined: 03 Apr 2006 Posts: 101 Location: USA
|
I concur with kimbert's view
But if there is a genuine reason/requirement as to why you need to know the number of children, you could do something like this in JavaCompute Node.
Quote: |
NOTE: Assuming you are in MRM domain |
MbMessage inMessage = contact admin.getMessage();
MbElement inMsgBody = inMessage.getRootElement().getLastChild();
int ItemNumCounter = inMsgBody.evaluateXPath("Content/N_PR/PR/PRLINE").size();
Had a Typo and had to edit the original  |
|
Back to top |
|
 |
siva.kasetty |
Posted: Thu Aug 21, 2008 10:43 pm Post subject: |
|
|
Apprentice
Joined: 17 Mar 2008 Posts: 45
|
Hi Kimbert,
I need to set a sequence number to a field in the output. This sequence depends on the number of occurences of PRLINE field in the input. When I use the input message set, the following line gives a warning:
SET ItemNumCounter=(InputRoot.MRM.Q1:Content.Q1:N_PR.Q1:PR.Q1:PRLINE[]);
as it is not accepting [] at the end. It does not give warning without [], but it will not get deploy without [].
As per the requirements, I have to use MRM for the input message. But I foudn that the followign line does not give any error/warning:
DECLARE ItemNumCounter INTEGER CARDINALITY(InputRoot.XML.N_PRIface.Content.N_PR.PR.PRLINE[]);
Can you pls tell, how do we find the CARDINALITY of PRLINE field in the input message when we use the MRM domain. OR Is there some other way of finding the occurences of a particular field in the input message?
We are using WMB V 6.0.2 |
|
Back to top |
|
 |
kimbert |
Posted: Fri Aug 22, 2008 12:54 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I need to set a sequence number to a field in the output |
That's an excellent reason for wanting to get the number of occurrences.
Quote: |
how do we find the CARDINALITY of PRLINE field in the input message when we use the MRM domain |
The same way as for any other domain, with one small caveat. Supply the field reference to the CARDINALITY function. As mentioned above. MRM field references do not contain the root element. |
|
Back to top |
|
 |
|