title: Matrix size Determination
body: <p>im supposed to work with xQuery and determine a matrix size. The Matrix has the format:</p>
  
  <pre><code>&lt;matrix&gt;
      &lt;row&gt;
          &lt;c&gt;1&lt;/c&gt;
          &lt;c&gt;2&lt;/c&gt;
          &lt;c&gt;3&lt;/c&gt;
      &lt;/row&gt;
      &lt;row&gt;
          &lt;c&gt;4&lt;/c&gt;
          &lt;c&gt;5&lt;/c&gt;
          &lt;c&gt;6&lt;/c&gt;
      &lt;/row&gt;
  &lt;/matrix&gt;
  </code></pre>
  
  <p>and what im currently trying to do is this:</p>
  
  <pre><code>xquery version "1.0"  encoding "UTF-8"; 
  module namespace wob="http://wob.iai.uni-bonn.de/exercises/xquery/matrix";
  
  declare function wob:dimensions($ma as element(matrix)) as xs:integer* {
      let $m := fn:count($ma/row)
      let $tmp := (for $currentRow in $ma/row
          return count($currentRow/c))
  
      let $result := ($m, $tmp[1])
  
      $result = (for $i in (2 to count($tmp))
          if ($tmp[1] != $tmp[$i])
          then return ()
          else ()
      )
  
      return $result
  };
  </code></pre>
  
  <p>coming from java, in my understanding this should return an empty sequence in case of unequal row widths. Because i want to return the matrix dimensions only if it is a valid matrix.</p>
  
  <p>parsing this with saxon, i get the error</p>
  
  <pre><code>Error on line 11 column 3 of matrixops.xqm:
    XPST0003 XQuery syntax error near #...lt := ($m, $tmp[1]) $result#:
      expected "return", found "$"
  </code></pre>
  
  <p>does this mean i cant assign it like that, or do i have to return something?</p>
  
  <p>besides, is there an ide to do this? seems very hard to learn to syntax because to me its really ugly.</p>