How to check the data for duplicates in xml

Hi all,
I have an xml similar to the below. In that I need an xquery which can remove the tags for which the data is same. For example in the below xml for first <customer> first <address> the <houseno>
and the second <address>'s <houseno> is same in that case there should be only one <houseno> tag with the data in the output xml. Please check the Input XML and Output XML xml formats below .
I am able to get the OUtputxml but with the same <houseno> repeating. I am not able to find a way in which I can chk the data and stop the tag getting created in the output.
Could you please suggest me the ways in which I can do. It would be of great help for me. Thanks a ton in advance.
Input XML
<customers>
     <customer>
          <address>
               <houseno>212</houseno>
                <phone>121221</phone>
          </address>
          <address>
               <houseno>212</houseno>
               <phone>42334</phone>             
          </address>
     <customer>
     <customer>
          <address>
               <houseno>3243</houseno>
               <phone>6565</phone>
          </address>
          <address>
               <houseno>3434</houseno>
                <phone>78778</phone>
          </address>
     </customer>
</customers>
Output XML Expected
<customers>
<customer>
          <address>
               <houseno>212</houseno>
                <phone>121221</phone>
                  <phone>42334</phone>              
          </address>
     <customer>
<customer>
          <address>
               <houseno>3243</houseno>
               <phone>6565</phone>
               <houseno>3434</houseno>
                <phone>78778</phone>
          </address>
     </customer>
</customers>
Output XML Which I am getting
<customers>
<customer>
          <address>
               <houseno>212</houseno>
                <houseno>212</houseno>        
                <phone>121221</phone>
                  <phone>42334</phone>              
          </address>
     <customer>
<customer>
          <address>
               <houseno>3243</houseno>
               <phone>6565</phone>
               <houseno>3434</houseno>
                <phone>6565</phone>
          </address>
     </customer>
</customers>
Regards

First of all the desired output.
[quote]
<customers>
<customer>
          <address>
               <houseno>212</houseno>
                <phone>121221</phone>
                  <phone>42334</phone>              
          </address>
     <customer>
<customer>
          <address>
               <houseno>3243</houseno>
               <phone>6565</phone>
               <houseno>3434</houseno>
                <phone>78778</phone>
          </address>
     </customer>
</customers>
[/quote]
I don't think this is a very good choice and will be causing trouble no end in a future stage of using the data...
I would rather propose a better choice to my thinking like this.
[code]
<customers>
    <customer>
          <address>
               <house houseno="212">
                   <phone>121221</phone>
                   <phone>42334</phone>
               </house>
          </address>
     </customer>
    <customer>
        <address>
            <house houseno="3243">
                <phone>6565</phone>
            </house>
            <house houseno="3434">
                <phone>78778</phone>
            </house>
       </address>
  </customer></customers>
[/code]
In that case, this is capable of producing the regrouped output.
[code]
<customers>{
    let $doc:=doc("your_data.xml")
    for $customer in $doc/customers/customer
    return
    <customer>{
        for $houseno in distinct-values($customer/address/houseno)
        return
        <house houseno="{$houseno}">{
           for $phone in $customer/address[houseno=$houseno]/phone
           return
           <phone>{data($phone)}</phone>
        }</house>
    }</customer>
}</customers>
[/code]

Similar Messages

  • How to check the data of an archived table.

    I have archived a table created by me. I have executed the write program for the archiving object in SARA. Now how can check the data of my archived table.

    Hello Vinod,
    One thing to check in the customizing settings is your "Place File in Storage System" option.  If you have selected the option to Store before deleting, the archive file will not be available for selection within the delete job until the store job has completed successfully.
    As for where your archive file will be stored - there are a number of things to check.  The archive write job will place the archive file in whatever filesystem you have set up within the /nFILE transaction.  There is a logical file path (for example ARCHIVE_GLOBAL_PATH)where you "assign" the physical path (for example UNIX: /sapmnt/<SYSID>/archivefiles).  The logical path is associated with a logical file name (for example ARCHIVE_DATA_FILE_WITH_ARCHIVE_LINK).  This is the file name that is used within the customizing settings of the archive object.
    Then, the file will be stored using the content repository you defined within the customizing settings as well.  Depending on what you are using to store your files (IXOS, IBM Commonstore, SAP Content Server, that is where the file will be stored. 
    Hope this helps.
    Regards,
    Karin Tillotson

  • How to get the date for the first monday of each month

    Dear Members,
    How to get the date for the first monday of each month.
    I have written the following code
    SELECT decode (to_char(trunc(sysdate+30 ,'MM'),'DAY'),'MONDAY ',trunc(sysdate+30 ,'MM'),NEXT_DAY(trunc(sysdate+30 ,'MM'), 'MON')) FROM DUAL
    But it look bith complex.
    Abhishek
    Edited by: 9999999 on Mar 8, 2013 4:30 AM

    Use IW format - it will make solution NLS independent. And all you need is truncate 7<sup>th</sup> day of each month using IW:
    select  sysdate current_date,
            trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month
      from  dual
    CURRENT_D FIRST_MON
    08-MAR-13 04-MAR-13
    SQL> Below is list of first monday of the month for this year:
    with t as(
              select  add_months(date '2013-1-1',level-1) dt
                from  dual
                connect by level <= 12
    select  dt first_of_the_month,
            trunc(dt + 6,'iw') first_monday_the_month
      from  t
    FIRST_OF_ FIRST_MON
    01-JAN-13 07-JAN-13
    01-FEB-13 04-FEB-13
    01-MAR-13 04-MAR-13
    01-APR-13 01-APR-13
    01-MAY-13 06-MAY-13
    01-JUN-13 03-JUN-13
    01-JUL-13 01-JUL-13
    01-AUG-13 05-AUG-13
    01-SEP-13 02-SEP-13
    01-OCT-13 07-OCT-13
    01-NOV-13 04-NOV-13
    FIRST_OF_ FIRST_MON
    01-DEC-13 02-DEC-13
    12 rows selected.
    SQL> SY.

  • How to name the data for each column I am acquiring in lvm file

    does anybody hint  How to name the data for each cloumn I am acquiring in lvm file.
    I want to tag or name ,eg temperature at top of a column which shows the temperature readings .I am writing into a labview measurement file.
    Thanks

    Use Set Waveform Attribute on each channel of your data.  Set an attribute with name "NI_ChannelName".  The value is a string containing the name you wish to call the channel.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • How to check the date and time when a material is blocked

    Hello,
       Please tell me how can i check the date and time when a material is blocked or unblocked.
    Regards,
    Priyanka

    Hi Pryianka,
    Are you speaking about blocked status of material master ('X-plant matl status' > MM03 > Basioc view 1; 'Plant-sp. matl status' > MM03 > MRP 1) or your problem is to find out the date when your material was booked into blocked state (stock category).
    If your problem is about mmr you can use the above mentioned MM04 (or MM03 > menu > Environment > Display changes).
    If your problem is to find out when your goods were posted to blocked stock you have to use MB51 + relevant movement types (e.g. 103, 344) + batch + etc. ()
    BR
    Csaba

  • How to populate the data for additional fields in custom report of fbl5n tr

    hallo friends,
    i ha ve to add some fields to the output of custome report of transaction FBL5N.
    Till now i have only added the fields to the output.
    Now i have to write the code to populate the data for those fields in the program.
    1.     Customer Credit Group(ACM/RCM): (Table: KNKK; Field Name: VKORG )
    2.     Credit Representative Group: (Table: KNKK; Field Name: SBGRP)
    3.     Customer Account Number(CAN#): (Table: KNKK; Field Name: KNKLI)
    4.     Alternative Payer(ALTP#) : (Table: KNA1; Field Name: KUNNR)
    5.     Risk Category: (Table: KNKK; Field Name: CTLPC)
    6.     Credit Info Number: (Table: KNKK; Field Name: KRAUS)
    7.     Rating: (Table: KNKK; Field Name: DBRTG)
    8.     Payment Index: (Table: KNKK; Field Name: DBPAY)
    9.     Credit control area: (Table: KNKK; Field Name: KKBER)
    10.     Company code: (Table: KNB1; Field Name: BUKRS)
    11.     Sales Organization: (Table: KNVV; Field Name: VKORG)
    These are al fields i have to populate in the program..
    MY ATTEMPTS:
    I tried getting the data for KNKK table by GET KNKK ,but it is giving some garbage values...
    And Logical database used here is DDF,and i have to add the VKORG of KNVV too...but KNVV is not there in DDF...
    Can anybody tell me how should i proceed..
    thanks in advance.

    Thnx Andreas,
    i have following doubts again..
    I have to add sales organisation field to the selection screen...(this is given in the req.)
    now if i will say GET KNKK...it would not keep account of this 'sales organisation' field...so how should i fetch the data with these input data( i.e. 'compny code' and 'customer' are the fields given by LDB and 'sales oraganisation' is the field i put it on the selection screen)
    And what about the KNVV-VKORG ,because the KNVV is not present in the LDB.

  • How to get the date for the last day of a week?

    Is there a easy way to get the date for the last day of week?
    eg a week starts on monday and end on sunday
    January 11, 2005 is the start date for the week
    January 17, 2005 is the end date for the week
    or
    say
    February 26, 2003 is the start date for the week
    March 5, 2003 is the end date for the week
    I just need a simple way of figuring that out....
    I figured out how to get the start date for the week but just can't get the latter..
    formatting of the date is not of a concern.. that I know how to do
    thanks in advance

    How about something like the following?
         Calendar someDay = new GregorianCalendar(2005,0,11);//2005 Jan, 11
         //Note above that January is 0, not 1, as counting starts from 0.
          someDay.add(Calendar.DAY_OF_MONTH,6); //add 6 days
         java.util.Date  lastDayOfWeek = someDay.getTime();
         //If someDay was the start of a week, lastDayOfWeek should now be
         //the last day of that week.
         System.out.println(lastDayOfWeek.toString() );

  • How to check the date is initial in the calculated keyfigure

    Hi,
    While calculating the difference between the two dates , i need to check the date is having the values or not in the calucluated key figures .how to achieve this .
    number of days = delviered date -  creation date
    All the dates are key figures
    Regards,
    Raj

    Hi there,
    It depends on what you want to retrieve.
    If you have this:
    day 1 - day 2
    If day 1 is initial, you'll have day 2 as the result of the difference which is correct. If in the other hand day1 is initial you'll have - day 2 as the result. So you just need the ABS() formula to give the absolute value of the difference.
    What exaclty do you want to achieve? only do the formula when both day 1 and day 2 have values? Retrieve always a positive value of the formula no matter if day 1 is initial or day 2 or both?
    Can you give a complete example with values of what's happening and what do you pretend to achieve?
    Diogo.

  • How to get the data for last 3rd business day and also include saturday and sunday if its a wednesday?

    Hi All,
    I have a simple query which is below:-
    Declare @reportdate date
    set @reportdate= (DATEADD(dd,-5,getdate()))
    select * from dbo.Table
    where date IN (@reportdate)
    I need this query to pull the data for the last 3rd business day .So lets say today is monday then i need the data for last week wednesday which is 3 business days back from monday, if today is a tuesday it would be for last thursday ( as 3 business days for
    tuesday would be thursday). But if today is wednesday then i need to be last 3rd business day which is last friday and i also need to get the data for saturday and sunday.
    Can someone please help me how cani change my filter to do this?
    Please let me know if i am still unclear.
    Thanks

    Hi SqlDev12,
    Based on my understanding on your requirement, you can reference the below sample.
    CREATE TABLE BusinessTable
    Bdate DATE,
    Wd VARCHAR(10)
    ;WITH Cte(DT,WD) AS
    SELECT CAST('20150401' AS DATE),DATENAME(WEEKDAY,CAST('20150401' AS DATE))
    UNION ALL
    SELECT DATEADD(DAY,1,DT),DATENAME(WEEKDAY,DATEADD(DAY,1,DT)) FROM Cte
    WHERE DT<GETDATE()
    INSERT INTO BusinessTable SELECT * FROM Cte
    SELECT * FROM BusinessTable
    SET DATEFIRST 7 -- Set Sunday as the first day of a week
    DECLARE @givenDay DATE ='20150415' --Wednesday
    SELECT * FROM BusinessTable
    WHERE Bdate BETWEEN
    --For Monday and Sunday, select last wednesday
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    --For Tuesday and Wednesday, last week's Thursday and Friday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3,4) THEN DATEADD(DAY,-5,@givenDay)
    --For Thursday and Friday, current week's Monday and Tuesday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    --For Saturday, current week's Wednesday
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    AND
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3) THEN DATEADD(DAY,-5,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(4) THEN DATEADD(DAY,-3,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    DROP TABLE BusinessTable
    If you have any feedback on our support, you can click
    here.
    Eric Zhang
    TechNet Community Support

  • NT - How to embed the date for the export output file?

    I want to know how to embed a date for the export file on Windows NT?
    Example :
    In Unix you can use a shell variable and attach to the file like exp file=exp_prod_$A,
    where $A will have the system date, My output will be like exp_prod_10012000.dmp.
    I want to know how to do the above on NT.
    Thanks
    Ravi
    null

    Welcome to the forum!
    When you want to post a block of code, you can enclose it with the mark ups { code }
    That is the key word code surrounded by curly brackets, but without the spaces
    You seem to be running a very old (and unsupported release of the database)
    7.3 has not been a current release for about 10 years.
    It's probably been that long since I've used this technique, but i think it should work.
    You should consider welcoming your system to the 21st century by upgrading to a supported release ;-)
    If you used split to chop up your export file, use cat or dd to reassemble it.
    So, something like this:
    mknod bk.dmp p
    cat xaa xab xac xad xae xaf xag xah xai > bk.dmp &
    imp SYSTEM/$PASSWD parfile=imp_bk.parfile
    rm bk.dmp
    $ cat imp_bk.parfile
    file=bk.dmp
    log=imp.log
    full=y
    buffer=1048576
    ignore=y
    commit=y let us know if still have problems.
    Good Luck!

  • How to check the data in a temporary table

    Hi,
    A procedure inserting data into a temporary table , data exists in the table now. so, how to see the data from the temporary table. Is it possible to see from the sqlplus by selecting, right now i'm not getting any data. .thanks Bcj.

    If you are referring to Global Temporary Tables, then the only way to see the contents of the table are to select from the table while connected to the same session that inserted the data into the GTT.
    Please note however that there is not a 1 to 1 correspondence between sessions and users (shcemas). A user may be connected to 1 or more sessions, but it is only the session that inserted the records that will be able to view the records.

  • How to check the DPI for images on pages

    hi,
            I want to check the DPI for images programatically, is there any function available in acrobat SDK,
            If not what other option we have to check the DPI for images programatically.
    Thank you,

    You don't mention which parts of the SDK, but you can use the Preflight feature of Acrobat via either JavaScript or C/C++ (plugin) to generate a report of images in a document and their information (including dpi).
    You can also write a plugin to iterate over each image individually and get its properties.

  • How to save the data for multiple sittings

    Hello All
    i have one sign up form. user enter only 4 to 5 fields & he may not fill the the manditory field & he left. but data base don’t give the error to him. but next day he will come at then he want to complet his sign up i.e. when he commit the all detail that time all validation will hapen.
    for that i use one table without constrain to store the temarory detail.& use other table (with constrains) for final submition.
    1) i creat the view n entity for temparory table
    2) & also i create views n entity for Final table
    n i create one methos in AmImple file in that file I create one method & expose to client n I drag n drop this method as a ADF Button & in that method I write the following logic
    1) taking the data from one view (from temporary table) & setting the value to other view(Final table).
    using this i set the value from tempary to final table...
    but when user left the manditory field then it allow to submit the data in temparory field but when i copy that data to final table(with constrain) n user submit the data then validation happn i.e. "this fild is mandatory".when i click this error message it goes to first screen.
    I try to implement this functionality…but its not working.
    can u plz suggest other way to implement this functionality in ADF using jdevloper11g
    Thanks in Advance

    User,
    I don't get it :-(
    How do you find out if a user comes back or is completely new? You have to have some information about the user to remember him. At least this information has to be mandatory (even for the temporary table).
    Let's assume you have figured out that the user has been on your page before:
    load his credentials from the temporary table to the form, let him fill in the rest and if he hit save save it in the final table.
    Timo

  • How to check  the date with current day after 5 days

    Hello,
    I need to make the visible of delete button in my struts application. I've application in which user can be deactivated. If the user is deactivated and the admin can't delete the user for the specific period of time (set in property file). while deactivating the user, system time is set. and 5 days after the system time's set, i need to make the button visible.
    This is my code.
    Calendar cal = Calendar.getInstance();
    Date deActivatedDate = null;
    deActivatedDate =new Date(userData.getDeActivatedTime().getTime());// Set it in the Calendar object
    cal.setTime(deActivatedDate);                    // Add 5 days
    cal.add(Calendar.DATE, 5);// get the current date
    Calendar currentCal = Calendar.getInstance();
    Date currentDate = new Date();
    currentCal.setTime(currentDate);// check if the de-activation time is over.
    if (cal.get(Calendar.DATE) < currentCal.get(Calendar.DATE)) {
    userData.setDeletionAllowed(true);}
    can anyone help to solve this issue?

    What's the problem with the code that you posted?

  • How to lock the data for few periods in the Input Layout

    Dear All,
    I have an input enabled layout wherein I will display the data based on a period range.( For ex, 01.2007 to 12.2007).
    Now, based on the current period I should disable the input readiness for the periods less than my current period.
    In my ex, if my current period is 06.2007, the input readiness should be disabled for the periods 01.2007 to 05.2007 .
    How can I achive this?
    Regards,
    Srini.

    Hi Srinivas.
    You can use user variable exit for the disabled one (the period one); based on the current period..
    You can read regarding it in here:
    http://help.sap.com/saphelp_nw04/helpdata/en/1d/ca10d858c2e949ba4a152c44f8128a/frameset.htm
    Hopefully it can help you a lot.
    Regards,
    Niel
    thanks for the points you choose to assign.

Maybe you are looking for

  • ERROR: JBO-26048 while createing a record.

    Hello, I have a table called ActivityTracker which has few Foreign Keys and one among them is for Activity_SubType (refering a table called Activity_Subtype). I am trying to insert a record in the ActivityTracker table using the following code: Entit

  • What is filling my disk?

    Disk usage on my MacBook Pro has grown dramatically recently, and I can not find the files that are responsible. My disk is 320GB and I am using 240GB but Finder only shows a usage of 29GB. Finders usage is reported as 3.8GB for Apps, 5.6GB for Libra

  • TS3694 My Iphone 4 won't update to IOS 6.0

    I tried to update to the IOS 6.0 but i keep getting error 3194 i updated to the latest update I tried to do everything but it wont update even when i tried updating through my iphone on my wifi i get an error on my phone too

  • Ovi Maps cannot read postal codes?

    I have a big problem with the functionality of Ovi Maps. All my addresses in my address book have postal codes (zip codes). When I click on the address in my Nokia N8 address book Ovi Maps opens but cannot find the address. When I edit the address in

  • Auto generate employee id

    Hi All, I am trying to follow the 2 day developer course. I am on "Building Your Application" => "Adding an Employees Report and Form". Point 11 says "In Define the source for the primary key columns, accept the default, Existing trigger, and click N