This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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>
Bug 9026 is related to this.
The XQuery WG intends that this should be considered in the XQuery Update 3.1 specification, but no such bugzilla classification currently exists.