title: How to populate a map in XQuery?
body: <p>I have an XML file in the following <a href="http://expirebox.com/download/3eb64bcb5a820ad8012ce65ca59d60e3.html" rel="nofollow">link</a></p>
  
  <p>I want to populate a map that with ids of movies and the average of their corresponding ratings. I am trying the following command from this <a href="https://docs.marklogic.com/guide/app-dev/hashtable#id_61683" rel="nofollow">site</a></p>
  
  <pre><code>for $doc in db:open("movies","movies.xml")/movies/movie
  let $map:= map:map()
  let $key := map:put($map, $doc/@id, avg($doc/ratings/child::node()))
  return $map 
  </code></pre>
  
  <p>However, it doesn't run. I get an exception, <code>Expecting variable declaration</code>. What am I doing wrong?</p>
  
  <p>EDIT:</p>
  
  <p>I am trying it the following command</p>
  
  <pre><code>let $map:=map{}
  for $doc in db:open("movies","movies.xml")/movies/movie
  return
  map:put($map,  
    $doc/@id,avg($doc/ratings/child::node())
  )
  </code></pre>
  
  <p>I get seperate maps</p>