Thanks to both.<div>But to preserve hierarchy and extended my previous example:<br></div><div><br></div><div><span class="Apple-style-span" style="border-collapse: collapse; "><div>A</div><div>&nbsp;&nbsp;- 1.xml</div><div>&nbsp;&nbsp;- 2.xml</div>
<div>B</div><div>&nbsp;&nbsp;- 3.xml&nbsp;</div><div>&nbsp;&nbsp;C</div><div>&nbsp;&nbsp; &nbsp;- 4.xml</div><div><br></div><div>If my WHERE clause is evaluated to TRUE in documents 2.xml, 3.xml and 4.xml.</div><div>I would like to have the following result</div>
<div><br></div><div><span class="Apple-style-span" style="border-collapse: separate; ">&lt;RESULTS&gt;<br>&lt;A&gt;2.xml&lt;A&gt;<br>&lt;B&gt;3.xml&lt;C&gt;4.xml&lt;/C&gt;&lt;/B&gt;</span></div><div><span class="Apple-style-span" style="border-collapse: separate; ">&lt;/RESULTS&gt;</span><br>
</div><div><span class="Apple-style-span" style="border-collapse: separate;"><br></span></div><div><span class="Apple-style-span" style="border-collapse: separate;">or a id/idref approach:</span></div><div><span class="Apple-style-span" style="border-collapse: separate;"><br>
</span></div><div><span class="Apple-style-span" style="border-collapse: separate;"><span class="Apple-style-span" style="border-collapse: collapse; "><div><span class="Apple-style-span" style="border-collapse: separate; ">&lt;RESULTS id=&quot;1&quot;&gt;<br>
&lt;A id=&quot;2&quot; refid=&quot;1&quot;&gt;2.xml&lt;A&gt;<br>&lt;B id=&quot;3&quot; refid=&quot;1&quot;&gt;3.xml&lt;/B&gt;</span></div><div><span class="Apple-style-span" style="border-collapse: separate;">&lt;C id=&quot;4&quot; refid=&quot;3&quot;&gt;4.xml&lt;/C&gt;</span></div>
<div><span class="Apple-style-span" style="border-collapse: separate; ">&lt;/RESULTS&gt;</span><br></div><div><span class="Apple-style-span" style="border-collapse: separate;"><br></span></div><div><span class="Apple-style-span" style="border-collapse: separate;">Thanks!!</span></div>
<div><span class="Apple-style-span" style="border-collapse: separate;"><br></span></div></span></span></div><div><span class="Apple-style-span" style="border-collapse: separate;"><br></span></div><div><br></div></span></div>
<div><br><div class="gmail_quote">2009/2/6 Wolfgang <span dir="ltr">&lt;<a href="mailto:wolfgang@exist-db.org">wolfgang@exist-db.org</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have his XQuery file:<br>
<br>
FOR $x in collection(&quot;A&quot;,&quot;B&quot;)<br>
WHERE ...<br>
RETURN ?<br>
<br>
If, for example, only the 2.xml and 3.xml were evaluate for TRUE in the WHERE clause, i want to obtain the following XML data:<br>
<br>
&lt;RESULTS&gt;<br>
&lt;A&gt;2.xml&lt;A&gt;<br>
&lt;B&gt;3.xml&lt;/B&gt;<br>
&lt;/RESULTS&gt;<br>
<br>
What should i put in the RETURN clause?<br>
</blockquote>
<br></div>
Function document-uri returns the URI of the document, which - for eXist - is the same as the collection path. Using standard xquery functions, you could extract the collection and document name as follows:<br>
<br>
for $m in (collection(&#39;/db/A&#39;), collection(&#39;/db/B&#39;))/*<br>
let $col := replace(document-uri(root($m)), &#39;^.*/(.*)/[^/]+$&#39;, &#39;$1&#39;)<br>
let $doc := replace(document-uri(root($m)), &#39;^.*/([^/]+$)&#39;, &#39;$1&#39;)<br>
return<br>
 &nbsp;element { $col } { $doc }<br>
<br>
Note that fn:collection does only allow one parameter (though older versions of eXist accepted more for historical reasons).<br><font color="#888888">
<br>
Wolfgang<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Ricardo Queirós<br>
</div>