title: XQuery - Help Needed
body: <p>I am supposed to write an XQuery based SQL script to merge data from 3 different XML files into one unified format
  .
  The output should be of the following format:</p>
  
  <pre><code>&lt;Courses&gt;
  &lt;Course school="NYU"&gt;
  &lt;Number&gt;30144&lt;/Number&gt;
  &lt;Title&gt;C‐PAC II&lt;/Title&gt;
  &lt;Instructor&gt;Lewis&lt;/Instructor&gt;
  &lt;/Course&gt;
  ...
  &lt;Course school="Harvard"&gt;
  &lt;Number&gt;4949&lt;/Number&gt;
  &lt;Title&gt;Computer Science 50. Introduction to Computer Science I&lt;/Title&gt;
  &lt;Instructor&gt;Michael D. Smith&lt;/Instructor&gt;
  &lt;/Course&gt;
  ...
  &lt;/Courses&gt;
  </code></pre>
  
  <p>I had written the following script to achieve the above:</p>
  
  <pre><code>SELECT catalog.query('
  &lt;Courses&gt;
  {
  (&lt;Course school = "NYU"&gt;
  {
  for $x in (/nyu/Course)
  return 
  &lt;Number&gt; {$x/CallNo/text()} &lt;/Number&gt;
  &lt;Title&gt; {$x/Name/text()} &lt;/Title&gt;
  &lt;Instructor&gt; {$x/Instructor/text()} &lt;/Instructor&gt;
  }
  &lt;/Course&gt;)
  
  union       
  
  (&lt;Course school = "Harvard"&gt;
  {
  for $y in (/harvard/Course)
  return
  &lt;Number&gt; {$y/Number/text()} &lt;/Number&gt;
  &lt;Title&gt; {$y/Title/text()} &lt;/Title&gt;
  &lt;Instructor&gt; {$y/Instructor/text()} &lt;/Instructor&gt;
  }               
  &lt;/Course&gt;)
  
  union
  
  (&lt;Course scool = "Umich"&gt;
  {
  for $z in (/umich/Course)
  return
  &lt;Number&gt; {$z/@catalognumber} &lt;/Number&gt;
  &lt;Title&gt; {$z/name/text()} &lt;/Title&gt;
  }
  &lt;/Course&gt;)
  }                       
  &lt;/Courses&gt;
  ')      
  from catalogs
  </code></pre>
  
  <p>Can anyone please tell me where I have went wrong?</p>