[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qexo-general] Duplicates/Distinct-Function
From: |
Sascha Opletal |
Subject: |
[Qexo-general] Duplicates/Distinct-Function |
Date: |
Sat, 29 Nov 2003 14:27:10 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 |
I need some distinct-values function for node-values and attribute-values:
I need to combine the attributes c="1" c="2" and c="1" with each other.
The attribute set
is called C. With two for-loops i built CxC, which is described in the
following.
Data is:
<a>
<b c="1">1</b>
<b c="2">2</b>
<b c="1">1</b>
</a>
First Xquery is:
for $a in doc("data2.xml")/a/b,
$b in doc("data2.xml")/a/b
return
<result>
{$a}
{$b} </result>
This gives:
<result>
<b c="1">1</b>
<b c="1">1</b>
</result><result>
<b c="1">1</b>
<b c="2">2</b>
</result><result>
<b c="1">1</b>
<b c="1">1</b>
</result><result>
<b c="2">2</b>
<b c="1">1</b>
</result><result>
<b c="2">2</b>
<b c="2">2</b>
</result><result>
<b c="2">2</b>
<b c="1">1</b>
</result><result>
<b c="1">1</b>
<b c="1">1</b>
</result><result>
<b c="1">1</b>
<b c="2">2</b>
</result><result>
<b c="1">1</b>
<b c="1">1</b>
</result>
Instead of this i need only equal pairs like this:
<result>
<b c="1">1</b>
<b c="1">1</b>
</result><result>
<b c="1">1</b>
<b c="1">1</b>
</result><result>
<b c="2">2</b>
<b c="2">2</b>
</result><result>
<b c="1">1</b>
<b c="1">1</b>
</result><result>
<b c="1">1</b>
<b c="1">1</b>
</result>
so i added the line
where $a/@c = $b/@c
to the for expression.
Now to be happy i need something to make sure no repeating takes place,
if there is more than one equal
attribute...the attributes are 1 2 1 and the last "1" is combined again
and gives the same result as the
first element "1"
The desired result would be:
<result>
<b c="1">1</b>
<b c="1">1</b>
</result><result>
<b c="2">2</b>
<b c="2">2</b>
</result>
Is there something like a set function where i can add an element and
check if it is already in there
or something else to achieve this?
- [Qexo-general] Duplicates/Distinct-Function,
Sascha Opletal <=