<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>27630</bug_id>
          
          <creation_ts>2014-12-16 18:10:01 +0000</creation_ts>
          <short_desc>Branching based on the XDM value returned by an updating expression</short_desc>
          <delta_ts>2015-02-10 11:16:55 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Update 3.1</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="John Snelson">john.snelson</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>andrew_coleman</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>116393</commentid>
    <comment_count>0</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2014-12-16 18:10:01 +0000</bug_when>
    <thetext>XQuery Update 3.0 still doesn&apos;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&apos;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
        &lt;access-attempt&gt;
          &lt;timestamp&gt;{fn:current-dateTime()}&lt;/timestamp&gt;
          &lt;user-name&gt;{$username}&lt;/user-name&gt;
          &lt;access-allowed&gt;{if($found) then &quot;Yes&quot; else &quot;No&quot;}
          &lt;/access-allowed&gt;
        &lt;/access-attempt&gt;
      into doc(&quot;log.xml&quot;)/*,
      $found
    )
};

declare variable $username as xs:string external;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
    &lt;head&gt;
      &lt;title&gt;Looking up user name&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
    {
      if(local:check-username($username)) then
        &lt;p&gt;Welcome, {$username}! Your previous login was:
        {
          doc(&quot;log.xml&quot;)//access-attempt[username = $username
            and access-allowed = &quot;Yes&quot;]/timestamp/string()
        }
        &lt;/p&gt;
      else
        &lt;p&gt;I don&apos;t know you!&lt;/p&gt;
    }
    &lt;/body&gt;
&lt;/html&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116394</commentid>
    <comment_count>1</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2014-12-16 18:10:33 +0000</bug_when>
    <thetext>Bug 9026 is related to this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116395</commentid>
    <comment_count>2</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2014-12-16 18:11:36 +0000</bug_when>
    <thetext>The XQuery WG intends that this should be considered in the XQuery Update 3.1 specification, but no such bugzilla classification currently exists.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>