- From: <bugzilla@jessica.w3.org>
- Date: Tue, 16 Dec 2014 18:10:01 +0000
- To: public-qt-comments@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27630 Bug ID: 27630 Summary: Branching based on the XDM value returned by an updating expression Product: XPath / XQuery / XSLT Version: Working drafts Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P2 Component: Update 3.0 Assignee: john.snelson@marklogic.com Reporter: john.snelson@marklogic.com QA Contact: public-qt-comments@w3.org XQuery Update 3.0 still doesn't have a way to make a decision based on the result of an updating expression. All the conditional expressions in the language are restricted from having an updating expression in their test expressions (if, typeswitch, switch, where etc.). In particular this makes it impossible to satisfy the following use case. There is also no way to assign the XDM value of an updating expression to a variable. Encapsulation Use Case This use case shows a function which checks if a given username is known and logs the event. Both the storage format for usernames and the fact that the event is being logged should be hidden from the function's caller (encapsulated), since these requirements could change later in the development process. declare %updating function local:check-username($username as xs:string) as xs:boolean { let $found := $username = collection()//user/@name return ( insert node <access-attempt> <timestamp>{fn:current-dateTime()}</timestamp> <user-name>{$username}</user-name> <access-allowed>{if($found) then "Yes" else "No"} </access-allowed> </access-attempt> into doc("log.xml")/*, $found ) }; declare variable $username as xs:string external; <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Looking up user name</title> </head> <body> { if(local:check-username($username)) then <p>Welcome, {$username}! Your previous login was: { doc("log.xml")//access-attempt[username = $username and access-allowed = "Yes"]/timestamp/string() } </p> else <p>I don't know you!</p> } </body> </html> -- You are receiving this mail because: You are the QA Contact for the bug.
Received on Tuesday, 16 December 2014 18:10:06 UTC