Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default 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.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default

    ??
    You're going to have to explain better than that.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default

    Another thing, what do you want as the output?
    Is it XML?

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by reach2sudhakar View Post
    this name value has to be set to a string element ABC in the target appl.
    Only he knows. ;)

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default

    This is definitely a "sit back and wait for clarification" one...:)

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  8. #8
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default

    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 07:49 AM. Reason: Moderator Edit: phone number deleted

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default

    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...

  10. #10
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default

    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..

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default

    Since this is some XML that you want to transform into some other XML, then Transform it, using an xslt.

    The idea of trying to do it manually is bonkers.

Similar Threads

  1. Repeating
    By AbdulAziz Bader in forum New To Java
    Replies: 3
    Last Post: 05-06-2010, 12:35 AM
  2. How to detect duplicate values in an Array?
    By maz09 in forum New To Java
    Replies: 1
    Last Post: 04-08-2010, 08:58 AM
  3. Replies: 1
    Last Post: 03-08-2010, 02:34 PM
  4. how to discard remainder on division?
    By RobertF in forum New To Java
    Replies: 9
    Last Post: 03-13-2009, 01:20 PM
  5. How to make a hashmap to allow duplicate values?
    By Preethi in forum New To Java
    Replies: 0
    Last Post: 02-08-2008, 01:35 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •