Hello,

I am using the exist db to store special kind of files which represent music being played for example,

  <layer n="1">
                                    <note xml:id="m2_s1_e1" pname="g" oct="5" dur="4" stem.dir="down"/>
                                    <note xml:id="m2_s1_e2" pname="d" oct="5" dur="8" stem.dir="down"/>
                                    <note xml:id="m2_s1_e3" pname="b" oct="4" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e4" pname="d" oct="5" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e5" pname="e" oct="5" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e6" pname="f" oct="5" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e7" pname="g" oct="5" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e8" pname="d" oct="5" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e9" pname="b" oct="5" dur="16" stem.dir="up"/>
      <note xml:id="m2_s1_e10" pname="d" oct="5" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e11" pname="b" oct="5" dur="16" stem.dir="up"/>
        <note xml:id="m2_s1_e12" pname="d" oct="5" dur="16" stem.dir="up"/>
                         </layer>
Here a note is a musical note with pitch name ranging from c to b. So user search string "gdb" then there are two matches,

<match n="1">
                                    <note xml:id="m2_s1_e1" pname="g" oct="5" dur="4" stem.dir="down"/>
                                    <note xml:id="m2_s1_e2" pname="d" oct="5" dur="8" stem.dir="down"/>
                                    <note xml:id="m2_s1_e3" pname="b" oct="4" dur="16" stem.dir="up"/>
                        </match>

<match n="2">
                                    <note xml:id="m2_s1_e7" pname="g" oct="5" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e8" pname="d" oct="5" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e9" pname="b" oct="5" dur="16" stem.dir="up"/>
                        </match>

And if user search is "dbd"  then there are three matches,

<match n="1">
                                   <note xml:id="m2_s1_e2" pname="d" oct="5" dur="8" stem.dir="down"/>
                                    <note xml:id="m2_s1_e3" pname="b" oct="4" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e4" pname="d" oct="5" dur="16" stem.dir="up"/>
                        </match>

<match n="2">
                                     
<note xml:id="m2_s1_e8" pname="d" oct="5" dur="16" stem.dir="up"/>
                                    <note xml:id="m2_s1_e9" pname="b" oct="5" dur="16" stem.dir="up"/>
      <note xml:id="m2_s1_e10" pname="d" oct="5" dur="16" stem.dir="up"/>
                        </match>
<match n="3">
                                     <note xml:id="m2_s1_e10" pname="d" oct="5" dur="16" stem.dir="up"/>
                            <note xml:id="m2_s1_e11" pname="b" oct="5" dur="16" stem.dir="up"/>
       <note xml:id="m2_s1_e12" pname="d" oct="5" dur="16" stem.dir="up"/>
                        </match>

here the node with xml:id="m2_s1_e10"   is repeatative which is the valid since it is repeating in two different matches. 

hope it is clear.

thanks raghu


On Wed, Aug 29, 2012 at 8:24 PM, Wolfgang Meier <wolfgang@exist-db.org> wrote:
> Approach 2
>
> Added all elements of all the matches into single NodeSet and left it to the the xquery to group it and present it to the user since xquery knows how many elements form a single match. This also fails because the NodeSet class does not allow duplicate elements. But my implementation has no duplicates within the same group which is a single match but same elements may apperár in a different group of match.
>
I do not understand yet what exactly you are trying to build, but I can at least answer the question concerning node sets: a NodeSet instance will always order the items in document order and remove duplicates. This is the general behavior required by the XQuery specs. If you need to create an unordered sequence of items allowing duplicates, you should use a ValueSequence. The value sequence preserves order and allows duplicates (until you call method toNodeSet on it).

Wolfgang