I have removed the duplicates entry based on one attributes in xml. My problem is need to remove the duplicates for comparing multiple attributes column.
Input
<Id>
<tbl_Keysight_Input Auto_Id="66365" Product_No="10070D" Product_Option="10070D"/>
<tbl_Keysight_Input Auto_Id="66365" Product_No="10070D" Product_Option="10070D"/>
<tbl_Keysight_Input Auto_Id="66365" Product_No="10070D1" Product_Option="10070D"/>
<tbl_Keysight_Input Auto_Id="66365" Product_No="10070D1" Product_Option="10070D"/>
<tbl_Keysight_Input Auto_Id="66365" Product_No="10070D" Product_Option="10070D"/>
</Id>
Expected output:
<Id>
<tbl_Keysight_Input Auto_Id="66365" Product_No="10070D" Product_Option="10070D"/>
<tbl_Keysight_Input Auto_Id="66365" Product_No="10070D1" Product_Option="10070D"/>
</Id>
Please provide the xquery for my requirement.
The below query is based on Auto_id only.
for $d in distinct-values(xdmp:directory("/documents/","1")//Id/tbl_Keysight_Input/@Auto_Id)
let $items := xdmp:directory("/documents/","1")/id/tbl_Keysight_Input[@Auto_Id = $d]
order by $d
return
for $i in $items [position() le 1]
return $i
fn:deep-equal()
? – har07deep-equal()
to determine equality between 2 elements (instead of comparing one attributes).. – har07