[xquery-talk] joining multiple queries into a single one

Titash Neogi titash_neogi at symantec.com
Tue Apr 11 04:08:22 PDT 2006


Dear All,

Please consider the following scenario.

I have XML content in a database. These files are of four categories.
tasks, concepts, refs and topics.

Task files are contained in <task> </task>
Concept files with <concept></concept>
And so on.

Withing each file there is a metadata that can be used for querying.
This metadata is similar for all for types of files.

<task>
<prolog>
 <meta>
	<filename>FILENAME A</filename>
	<lang>ENG</lang>
	<nature>SOME</nature>
	<id>8990</id>
 </meta>
</prolog>
...
...
...
</task>


<concept>
<prolog>
 <meta>
	<filename>FILENAME B</filename>
	<lang>HND</lang>
	<nature>SOME</nature>
	<id>82230</id>
 </meta>
</prolog>
...
...
...
</concept>

And so on for other files.

My problem is -

I am trying to a write a query that can search and extract content from
all these types of files. I know how to write a query for individual
file types but I want to write a single query for all four file types.
Here is an example -

Currently my query looks something like this

for $r in //task where $r/prolog/meta/filename/text()="xys" return $r

for $r in //concept where $r/prolog/meta/filename/text()="xys" return $r


I want to do away with this redundancy and write a single query for this
which works on all four file types in the database. 

I am using the eXist Native XML Database. My content files are the path
/db/content


If I write a query such as 

For $r in /db/content where $r//prolog/meta/filename/text()="xys" 

this doesn't seem to work.

Please advice.

Thanks and regards
Titash




More information about the talk mailing list