[xquery-talk] If Statements within an If Statement?

Wei, Alice J. ajwei at indiana.edu
Wed Apr 2 15:32:46 PST 2008


Hi, David:

  Thanks, this did do the trick.

Alice
======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei at indiana.edu
________________________________________
From: David Carlisle [davidc at nag.co.uk]
Sent: Wednesday, April 02, 2008 1:47 PM
To: Wei, Alice J.
Cc: talk at x-query.com
Subject: Re: [xquery-talk] If Statements within an If Statement?

You are passing in a sequence of ad elements,


so $seq[.=$d][1] is an ad element

so

$seq[.=$d][1]/ancestor::ad

is empty, as your ad elements don't have any ancestor at all, definitely
not an ancestor named ad.


and all the variables you declare in the let clause are empty.

perhaps you meant


let $head := $seq[.=$d][1]/descendant::head[1]

but that's just a guess.

If you do that then
let $para := $seq[.=$d][1]/descendant::p

will be a sequence of p elements so you don't want

<p>{$para}</p>


which will put p in p, just

{$para}


David

PS

foo//p[1]

will not always return just one elemet, which appears to be what you
intent, it will return every p that is the first child of its pareent.

foo//descendant::p[1]

on the other hand just returns the first p in foo, which is why I
changed your examples aboev, in addition to removing the spurious
ancestor axis.



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________



More information about the talk mailing list