Author |
Message
|
hikari_sukunami |
Posted: Thu Sep 26, 2013 12:41 am Post subject: How to find a certain attribute in xmlnsc? |
|
|
Newbie
Joined: 26 Sep 2013 Posts: 6
|
Hi,
I have an xmlnsc just like this:
<abc:CommandRequestData xmlns:abc="<can't post the url here>">
<abc:Environment>
<abc:Parameter name="ApplicationDomain" value="CAO_LDM_00"/>
</abc:Environment>
<abc:Command>
<abc:Operation namespace="CA" name="Recharge">
<abc:ParameterList>
<abc:StringParameter name="CustomerId">639474210070</abc:StringParameter>
<abc:StringParameter name="AccessKey">639474210070</abc:StringParameter>
<abc:StringParameter name="EventName">flexible</abc:StringParameter>
<abc:LongParameter xsi:type="abc:LongParameter" name="AmountOfUnits">1500</abc:LongParameter>
<abc:StringParameter name="EventClass">flexible</abc:StringParameter>
<abc:ListParameter name="RatingInput">
<abc:StringElement>CSP</abc:StringElement>
<abc:StringElement>OnPeakAccountID</abc:StringElement>
<abc:StringElement>3</abc:StringElement>
<abc:StringElement>1</abc:StringElement>
<abc:StringElement>20110718183457</abc:StringElement>
</abc:ListParameter>
<abc:LongParameter xsi:type="abc:LongParameter" name="MessageId">256118092</abc:LongParameter>
<abc:StringParameter name="EventInfo">CSP|MWRLI|||09194400106|15.00|</abc:StringParameter>
</abc:ParameterList>
</abc:Operation>
</abc:Command>
</abc:CommandRequestData>
What I need to do is to get this <abc:StringParameter name="CustomerId">639474210070</abc:StringParameter>
I need to make a loop in the abc:ParameterList and check if there is a StringParameter whose attribute is CustomerId is existing. If found, I should get its value (that is 639474210070).
The values in ParameterList is dynamic. Meaning the order can be reshuffle.
Say From this one:
<abc:ParameterList>
<abc:StringParameter name="CustomerId">639474210070</abc:StringParameter>
<abc:StringParameter name="AccessKey">639474210070</abc:StringParameter>
<abc:StringParameter name="EventName">flexible</abc:StringParameter>
<abc:LongParameter xsi:type="abc:LongParameter" name="AmountOfUnits" >1500</abc:LongParameter>
<abc:StringParameter name="EventClass">flexible</abc:StringParameter>
<abc:ListParameter name="RatingInput">
<abc:StringElement>CSP</abc:StringElement>
<abc:StringElement>OnPeakAccountID</abc:StringElement>
<abc:StringElement>3</abc:StringElement>
<abc:StringElement>1</abc:StringElement>
<abc:StringElement>20110718183457</abc:StringElement>
</abc:ListParameter>
<abc:LongParameter xsi:type="abc:LongParameter" name="MessageId" >256118092</abc:LongParameter>
<abc:StringParameter name="EventInfo">CSP|MWRLI|||09194400106|15.00|</abc:StringParameter>
</abc:ParameterList>
to this one:
<abc:ParameterList>
<abc:StringParameter name="AccessKey">639474210070</abc:StringParameter>
<abc:StringParameter name="CustomerId">639474210070</abc:StringParameter>
<abc:StringParameter name="EventName">flexible</abc:StringParameter>
<abc:LongParameter xsi:type="abc:LongParameter" name="AmountOfUnits" >1500</abc:LongParameter>
<abc:StringParameter name="EventClass">flexible</abc:StringParameter>
<abc:ListParameter name="RatingInput">
<abc:StringElement>CSP</abc:StringElement>
<abc:StringElement>OnPeakAccountID</abc:StringElement>
<abc:StringElement>3</abc:StringElement>
<abc:StringElement>1</abc:StringElement>
<abc:StringElement>20110718183457</abc:StringElement>
</abc:ListParameter>
<abc:LongParameter xsi:type="abc:LongParameter" name="MessageId">256118092</abc:LongParameter>
<abc:StringParameter name="EventInfo">CSP|MWRLI|||09194400106|15.00|</abc:StringParameter>
</abc:ParameterList>
How will I do this?
This is what I did but it only works if the CustomerId attribute is the first attribute in the ParameterList. Hence it is not working if the CustomerId is in different position.
SET J = CARDINALITY(input.doc:AtomicRequest.abc:CommandRequestData.abc:Command.abc:Operation.abc:ParameterList.*[]);
WHILE I <= J DO
SET Environment.StringParam = input.doc:AtomicRequest.abc:CommandRequestData.abc:Command.abc:Operation.abc:ParameterList.*[I];
IF input.doc:AtomicRequest.abc:CommandRequestData.abc:Command.abc:Operation.abc:ParameterList.abc:StringParameter.*[I] IS NOT NULL THEN
IF input.doc:AtomicRequest.abc:CommandRequestData.abc:Command.abc:Operation.abc:ParameterList.abc:StringParameter.*[I] = 'CustomerId' THEN
SET Environment.msisdn = input.doc:AtomicRequest.abc:CommandRequestData.abc:Command.abc:Operation.abc:ParameterList.*[I];
END IF;
END IF;
Thank you  |
|
Back to top |
|
 |
McueMart |
Posted: Thu Sep 26, 2013 12:55 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
You can use SELECT statements on the logical message tree, just like how you use SELECT statements to select data out of a database.
Your problem should be very easy to solve using a SELECT statement. Have a go and let us know if you hit problems. |
|
Back to top |
|
 |
aggarwal.intouch |
Posted: Thu Sep 26, 2013 2:01 am Post subject: |
|
|
 Acolyte
Joined: 30 May 2011 Posts: 56 Location: India
|
|
Back to top |
|
 |
dogorsy |
Posted: Thu Sep 26, 2013 2:12 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
It is a good idea to refer to the documentation that is relevant to the release the OP is using, as it might have changed.
Please note that that documentation is talking about the XMLNS parser and the OP might be using XMLNSC parser, in which case he should be using XMLNSC.Attribute, rather than XML.Attribute. |
|
Back to top |
|
 |
hikari_sukunami |
Posted: Tue Oct 01, 2013 1:21 am Post subject: |
|
|
Newbie
Joined: 26 Sep 2013 Posts: 6
|
I tried this one but it is not working.
SET OutputRoot.XMLNSC.cri:criInput.min = THE (SELECT ITEM FIELDVALUE(T) FROM input.doc:AtomicRequest.nsn:CommandRequestData.nsn:Command.nsn:Operation.nsn:ParameterList[] AS T WHERE FIELDVALUE(T.(XMLNSC.Attribute)name) = 'CustomerId'); |
|
Back to top |
|
 |
dogorsy |
Posted: Tue Oct 01, 2013 1:35 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
1- input is not a correlation name, so maybe you should try InputRoot.XMLNSC etc. Ensure the path is correct.
2- nsn:ParameterList[] contains children, which is what you want to search, so this should be nsn:ParameterList.*:*[]
3- run the flow and get a user trace. By reading the user trace you will get a better idea of what is going wrong. |
|
Back to top |
|
 |
hikari_sukunami |
Posted: Tue Oct 01, 2013 1:49 am Post subject: |
|
|
Newbie
Joined: 26 Sep 2013 Posts: 6
|
Thank you all
It's working now.
DECLARE input REFERENCE TO Environment.Variables.Input.OriginalMessage;
SET OutputRoot.XMLNSC.cri:criInput.min = THE (SELECT ITEM FIELDVALUE(T) FROM input.doc:AtomicRequest.nsn:CommandRequestData.nsn:Command.nsn:Operation.nsn:ParameterList.*[] AS T WHERE FIELDVALUE(T.(XMLNSC.Attribute)name) = 'CustomerId'); |
|
Back to top |
|
 |
dogorsy |
Posted: Tue Oct 01, 2013 2:09 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
Good and well done.
You can impove performance by limiting the children you are searching: instead of
Code: |
nsn:ParameterList.*[] |
you can use
Code: |
nsn:ParameterList.abc:StringParameter[] |
as these are the ones that contain the customer id |
|
Back to top |
|
 |
hikari_sukunami |
Posted: Tue Oct 01, 2013 2:16 am Post subject: |
|
|
Newbie
Joined: 26 Sep 2013 Posts: 6
|
wow! I'll try that too.
Thank you dogorsy!  |
|
Back to top |
|
 |
|