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

David Carlisle davidc at nag.co.uk
Wed Apr 2 18:47:27 PST 2008




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