javaxmlxqueryosboracle-service-bus

Getting distinct Values from XML in java, OSB, XQuery


<data>  
  <info>  
    <name>A</name>  
  </info>  
  <info>  
    <name>B</name>  
  </info>  
  <info>  
    <name>A</name>  
  </info>  
<info>  
    <name>C</name>  
  </info>  
<info>  
    <name>B</name>  
  </info>  
</info>  

Is there any way to get result like in java or OSB or in Xquery distinct-values is not working in Oracle service bus so i want made java method to get unique names

<data>  
<info>  
<name>A</name>  
</info>  
<info>  
<name>B</name>  
</info>   
<info>  
<name>C</name>  
</info>  
</data>  

Solution

  • I have solved like this

    <CUSTOMER_NO_1>{ 
        (for $test in fn:distinct-values($data_ENV1/ns0:data/ns0:CUST/ns0:CUSTNO)
            return $test)[1]
    }</CUSTOMER_NO_1>
    <CUSTOMER_NO_2>{    
        (for $test in fn:distinct-values($data_ENV1/ns0:data/ns0:CUST/ns0:CUSTNO)
            return $test)[2]
    }</CUSTOMER_NO_2>
    <CUSTOMER_NO_3>{    
        (for $test in fn:distinct-values($data_ENV1/ns0:data/ns0:CUST/ns0:CUSTNO)
            return $test)[3]
    }</CUSTOMER_NO_3>
    <CUSTOMER_NO_4>{    
        (for $test in fn:distinct-values($data_ENV1/ns0:data/ns0:CUST/ns0:CUSTNO)
            return $test)[4]
    }</CUSTOMER_NO_4>
    <CUSTOMER_NO_5>{    
        (for $test in fn:distinct-values($data_ENV1/ns0:data/ns0:CUST/ns0:CUSTNO)
            return $test)[5]
    }</CUSTOMER_NO_5>
    <CUSTOMER_NO_6>{    
        (for $test in fn:distinct-values($data_ENV1/ns0:data/ns0:CUST/ns0:CUSTNO)
            return $test)[6]
    }</CUSTOMER_NO_6>
    <CUSTOMER_NO_7>{    
        (for $test in fn:distinct-values($data_ENV1/ns0:data/ns0:CUST/ns0:CUSTNO)
            return $test)[7]
    }</CUSTOMER_NO_7>