[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.

	<filename>FILENAME A</filename>

	<filename>FILENAME B</filename>

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

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

More information about the talk mailing list