[xquery-talk] Printing Siblings in Functions

Wei, Alice J. ajwei at indiana.edu
Sun Mar 2 20:47:58 PST 2008

Hi, Florence:

  Sorry for not making this clear enough.
 What I am intending to do is to select the "entire" head element as long as any of the siblings have "SCHOOL" in them.

Therefore, for a fragment like the one in the following, even though the word "School" is contained only in the <head> element where @type='main', I wanted to extract the entire <head> element.

Is this possible?

Here is the query again:

declare variable $data :=
<head type ="main">High School
Diploma &amp; Ring</head>
<head type ="sub">YOURS Through Home Study</head>
<p>Prepare for GED or College Entrance
<addressLine>400 N. Interurban Richardson,</addressLine>
<addressLine>Texas 75080</addressLine>
<emph rend ="bold">Texts Purchased by: Departments of Education·Private
Mail this Coupon NOW. For Persons 18 or Over
<addressLine>United Schools and Services Dept. M676</addressLine>
<addressLine>Box 1068, Richardson, Texas 75080</addressLine>
<p>Please rush FREE information about High School</p>
declare variable $s := $data/head[contains(upper-case(.),
declare function local:unique-nodes-by-value($seq as element()*) as
for $d in distinct-values($seq)
let $head := $seq/parent::ad/descendant::head
 return  <ad>{$head[. = $d][1]}</ad>

Thanks for your help.
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei at indiana.edu
From: Florent Georges [lists at fgeorges.org]
Sent: Sunday, March 02, 2008 6:25 PM
To: Wei, Alice J.
Subject: Re: [xquery-talk] Printing Siblings in Functions

"Wei, Alice J." wrote:

> $data/head[contains(upper-case(.), 'SCHOOL')];
> [...]
>  My intended output is as follows:
> [...]
> <head type ="sub">YOURS Through Home Study</head>
> [...]
> Have I done something wrong?

  The expected head element doesn't match the predicate you are using
to select head elements.


Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr

More information about the talk mailing list