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

If Statements within an If Statement?

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


  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. 
________________________________________________________________________


Purchase Stylus Studio Online Today!

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

Buy Stylus Studio Now

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.