Results 1 to 11 of 11
- 09-10-2010, 09:47 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 22
- Rep Power
- 0
Discard duplicate or repeating values in the xml.
HI,
Can you pls help me in writing the logic for this.
<Main>
<subgroup1>
<name>name1</name>
<name>name1</name>
<name>name1</name>
<name>name1</name>
<name>name2</name>
<name>name2</name>
<name>name1</name>
<name>name3</name>
<name>name2</name>
<name>name1</name>
<name>name2</name>
<name>name4</name>
<name>name1</name>
</subgroup1>
<subgroup2>
<name>name1</name>
<name>name1</name>
<name>name3</name>
<name>name1</name>
<name>name2</name>
<name>name2</name>
<name>name1</name>
<name>name3</name>
<name>name2</name>
<name>name1</name>
<name>name2</name>
<name>name4</name>
<name>name1</name>
<name>name2</name>
</subgroup>
</Main>
Here I have to write the code in the FMD catridge in such a way that it has to map the name values in a unique way only not to repeate the duplicate values inside each sub group.It has to set only one unique element per subgroup. Please advice how to do this functionality, and this name value has to be set to a string element ABC in the target appl.
Thanks,
Raj.
- 09-10-2010, 12:49 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
??
You're going to have to explain better than that.
- 09-10-2010, 01:42 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
How did you read the first element of the XML file, can you show it here?
- 09-10-2010, 01:46 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Another thing, what do you want as the output?
Is it XML?
- 09-10-2010, 01:49 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 09-10-2010, 01:54 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
This is definitely a "sit back and wait for clarification" one...:)
- 09-10-2010, 02:04 PM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 09-11-2010, 05:14 AM #8
Member
- Join Date
- Sep 2010
- Posts
- 22
- Rep Power
- 0
Hi,
Thanks for your responses. As I told you it is an xml file, then I have java code to retrieve the xml elements. here under the subgroup complex type name element is of type unbounded, and this element will have same values repeating, so what my requirement is I need to have a unique name(s) element per subgroup like
<ABC>name1</ABC>
<ABC>name2</ABC>
<ABC>name3</ABC>
like that.
and this unique name element I am mapping to another xml element ABC. Here I gave sample input only. may be the xml is not with valid structure, but I hope you understand what my requirement is. Here both source element <name> and target element <ABC> are of type string only. Please advice the java logic with the use of if statements. As I am working in FMD( Financial Message Designer) catride, i can't use java collection API's like set and treeSet.
Let me explain you how I am trying.
first I am defing one Array variable test=["abc"];
def a = $main.subgroup1.name;
then iam adding all the name values into this array like - test.add(a);
then looping till end of the test length, then checking if (test[i]!=a) or (test[i]!= $main.subgroup1.name){//do nothing}
else
main.subgroup.ABC= $main.subgroup1.name;
break;
something like that, but this logic didn't work. it is repeatdly dispaying the name element with repeated values like
<ABC>name1</ABC> or it is deisplaying as <ABC>name1</name>
<ABC>name1</ABC> <ABC/>
<ABC>name2</ABC> <ABC>name2</ABC>
<ABC>name1</ABC> <ABC>name1</ABC>
<ABC>name2</ABC> <ABC>name2</ABC>
<ABC>name2</ABC> <ABC/>
I want llike:
<ABC>name1</ABC>
<ABC>name2</ABC>
Please do advice how to make this unique which are coming in each subgroup.
If you feel it is interesting and want to help me, please dont mind me and call me on my mobile number: <deleted>.
Thanks,
Raj.Last edited by Fubarable; 09-11-2010 at 06:49 AM. Reason: Moderator Edit: phone number deleted
- 09-12-2010, 12:00 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
So, is this Java you are trying to write this in, or is this an xslt?
I'm trying to figure out what language I'm looking at in your post...
- 09-23-2010, 12:12 PM #10
Member
- Join Date
- Sep 2010
- Posts
- 22
- Rep Power
- 0
Hi,
Yeah it is basically written with the use of java syntax only. but this code is in Oracle Financial Message Driver catrridge.
Logic has to be implement in java only..
- 09-23-2010, 12:59 PM #11
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Repeating
By AbdulAziz Bader in forum New To JavaReplies: 3Last Post: 05-05-2010, 11:35 PM -
How to detect duplicate values in an Array?
By maz09 in forum New To JavaReplies: 1Last Post: 04-08-2010, 07:58 AM -
Custom Validator for checking duplicate values with database
By tanalyw in forum Web FrameworksReplies: 1Last Post: 03-08-2010, 01:34 PM -
how to discard remainder on division?
By RobertF in forum New To JavaReplies: 9Last Post: 03-13-2009, 12:20 PM -
How to make a hashmap to allow duplicate values?
By Preethi in forum New To JavaReplies: 0Last Post: 02-08-2008, 12:35 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks