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

flowrrr - how to structure a function?

Peter pc.subscriptions at gmail.com
Tue Oct 17 14:02:19 PDT 2006


  flowrrr - how to structure a function?
Rob,

Without trying it, what you have written seems fine to me. You could inline
some things but it should, at least in theory, not make a difference

One thing to be aware of is that you have no guarantee (again in theory)
that the order in which function calls are evaluated match the order in
which you write them.

So theoretically an XQuery engine might choose to first evaluate 

session:set-attribute($project-key,
$group-name),response:redirect-to(xs:anyURI("./project/"))

before it evaluates the other function calls in the deepest return.

Hth,

Peter


> -----Original Message-----
> From: http://x-query.com/mailman/listinfo/talk [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf
> Of Robert Koberg
> Sent: Tuesday, October 17, 2006 12:16 PM
> To: http://x-query.com/mailman/listinfo/talk
> Subject:  flowrrr - how to structure a function?
> 
> Hi, (I am a newbie)
> 
> Is it appropriate (necessary?) to nest return statements.
> 
> Is there a better way to write the function below? I only want to get
> the $db-ref string and $db-instance nodeset 'if the user is valid'.
> 
> -------------------------------
> declare function local:enter-project() as element()? {
>    let $is-valid := local:is-valid-user-for-group()
>    return
>      if ($is-valid) then
>        let $db-ref := request:get-parameter("db-ref", ""),
>            $db-instance := doc(databases.xml")/*/instance[@id=$db-ref]
>        return
>          (
>            session:set-attribute("rest-db-uri",
> fn:string($db-instance/rest-uri)),
>            session:set-attribute("xmlprc-db-uri",
> fn:string($db-instance/xmlprc-uri)),
>            session:set-attribute("webdav-db-uri",
> fn:string($db-instance/webdav-uri)),
>            session:set-attribute($project-key, $group-name),
>            response:redirect-to(xs:anyURI("./project/"))
>          )
>      else
>        <p class="warn">Could not find credentials to let you enter the
> project.</p>
> };
> 
> thanks,
> -Rob
> 
> 
> 
> _______________________________________________
> 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

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.