[xquery-talk] Using Union Operator without Duplicate Records

Alice Wei ajwei at indiana.edu
Sat Dec 29 23:06:36 PST 2007

Alice Wei wrote:

Thanks, now it is working a lot better than before. But there is one 
little problem, since I have other "children" under project that are 
not to be selected in this set of XQuery, is it not possible to just 
state some for statements instead of putting in the entire code?

The other thing is, I have placed all the other "sections" within the 
original XML file into this code, and now the output from A-R is 
running in an orderly fashion. But, somehow the one that has the first 
name with an S is at the beginning of the list.

For both questions, could you please send, as before, a Minimal 
Complete Sample? That is, a sample with a complete input, the query you 
wrote so far, and your expected output. The input and the query should 
be as minimal as possible, but still reproducing the problem and 
complete (so readers of the list could run it easily).

   The issue is that I have a lot of similar structures like the small 
set of XML in the following example. What I intend to do is to only 
"extract" the author part and order them using distinct-values.


<project_title>Poetry in XML</project>
<author type="co-author">Gene Pidzarko</author>
<author type="Faculty">Chris Lee</author>
<description>Using XML to encode scholarly texts.</description>

    The code below works great, but is it possible to shorten the "for" 
clause so that it looks something like

for $project in doc("resume_2.xml")//author

without using the XML embedded inside to shorten the code?

The XQuery:

declare boundary-space preserve;
for $a in
<author type="co-author">Gene Pidzarko</author>
<author type="Faculty">Chris Lee</author>
/ distinct-values(.//author[@type = ('co-author', 'Faculty')]) order by 
$a ascending return <author> { data($a) } </author>

Thanks for your help.




Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! 

_______________________________________________ talk at x-query.com 

Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei at indiana.edu

More information about the talk mailing list