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

有什么方法可以像在 java 或 OSB 或 Xquery 中那样获得结果, distinct-values 在 Oracle 服务总线中不起作用,所以我想让 java 方法获取唯一名称

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

2 回答 2

2

我假设您想根据名称值对所有信息元素进行分组,并从每个组中只输出一个信息?

let $data :=
<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>  
</data>  
return
  <data>{
    let $distinct-names := distinct-values($data/info/name)
    for $name in $distinct-names
    let $infos := $data/info[name eq $name]
    return
      $infos[1]
  }</data>

我认为您也可以使用“分组依据”扩展名:

let $data :=
<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>  
</data>  
return
  <data>{
    for $info in $data/info
    group $info as $infos by $info/name as $name
    return 
      $infos[1]
  }</data>

上述两个查询都返回:

<data>
  <info><name>A</name></info>
  <info><name>B</name></info>
  <info><name>C</name></info>
</data>
于 2013-12-10T17:53:52.797 回答
0

我已经这样解决了

<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>
于 2014-03-17T07:51:19.243 回答