[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?

David Carlisle davidc at nag.co.uk
Tue Oct 17 12:57:35 PDT 2006


  flowrrr - how to structure a function?
not sure that its better, but is-valid is only used once
and has quite small definitions so you don't need to declare
it, just inline the definition, which gets rid of one layer of
return that you were asking about.

declare function local:enter-project() as element()? {
     if (local:is-valid-user-for-group()) 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", 
  string($db-instance/rest-uri)),
           session:set-attribute("xmlprc-db-uri", 
  string($db-instance/xmlprc-uri)),
           session:set-attribute("webdav-db-uri", 
  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>
};


you could get rid of the other let - return clause as well if you prefer
a more xpath style:


declare function local:enter-project() as element()? {
     if (local:is-valid-user-for-group()) then
      doc(databases.xml")/*/instance[@id=request:get-parameter("db-ref", "")]/
         (
           session:set-attribute("rest-db-uri",  string(rest-uri)),
           session:set-attribute("xmlprc-db-uri", string(xmlprc-uri)),
           session:set-attribute("webdav-db-uri", string(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>
};




David


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.