[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Printing Siblings in Functions

=?GB2312?B?1dTA1w==?= zhaolei at gmail.com
Mon Mar 3 11:10:50 PST 2008


  Printing Siblings in Functions
>  declare function local:unique-nodes-by-value($seq as element()*) as
>  element()*
>  {
>  for $d in distinct-values($seq)
>  let $head := $seq/parent::ad/descendant::head
>   return  <ad>{$head[. = $d][1]}</ad>
>  };

Not very sure about your requirement. Does the "entire head" mean all
the head children under an "ad" node, which has a head child that
contains "school"?

But according to the expected result, you should remove the filter
condition from the return clause, like follows:

>   return  <ad>{$head}</ad>

Regards,
Lei


On 3/3/08, Wei, Alice J. <http://x-query.com/mailman/listinfo/talk> wrote:
> 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 :=
>  <ad>
>  <head type ="main">High School
>  <lb/>
>  Diploma &amp; Ring</head>
>  <head type ="sub">YOURS Through Home Study</head>
>  <description>
>  <p>Prepare for GED or College Entrance
>  <address>
>  <addressLine>400 N. Interurban Richardson,</addressLine>
>  <addressLine>Texas 75080</addressLine>
>  </address>
>  </p>
>  <p>
>  <emph rend ="bold">Texts Purchased by: Departments of Education·Private
>  Schools·Colleges</emph>
>  Mail this Coupon NOW. For Persons 18 or Over
>  <address>
>  <addressLine>United Schools and Services Dept. M676</addressLine>
>  <addressLine>Box 1068, Richardson, Texas 75080</addressLine>
>  </address>
>  </p>
>  <p>Please rush FREE information about High School</p>
>  </description>
>  </ad>;
>  declare variable $s := $data/head[contains(upper-case(.),
>  'SCHOOL')];
>  declare function local:unique-nodes-by-value($seq as element()*) as
>  element()*
>  {
>  for $d in distinct-values($seq)
>  let $head := $seq/parent::ad/descendant::head
>   return  <ad>{$head[. = $d][1]}</ad>
>  };
>  local:unique-nodes-by-value($s)
>
>
> Thanks for your help.
>
> ======================================================
>  Alice Wei
>  MIS 2008
>  School of Library and Information Science
>  Indiana University Bloomington
>  http://x-query.com/mailman/listinfo/talk
>  ________________________________________
>
> From: Florent Georges [http://x-query.com/mailman/listinfo/talk]
>  Sent: Sunday, March 02, 2008 6:25 PM
>  To: Wei, Alice J.
>  Subject: Re:  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.
>
>   Regards,
>
>  --drkm
>       _____________________________________________________________________________
>  Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr
>
>
>
>  _______________________________________________
>  http://x-query.com/mailman/listinfo/talk
>  http://x-query.com/mailman/listinfo/talk
>



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.