title: XQuery cardinality error on outputting results to text file
body: <p>Using XQuery 3.1 (under eXistDB 4.4), I have a function which returns a  serialized output of 710 delimited rows like these:</p>
  
  <pre><code>MS609-0001~ok~0001~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~self~1245-05-27~Arnald_Garnier_MSP-AU~self
  MS609-0002~ok~0002~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~MS609-0001~1245-05-27~Guilhem_de_Rosengue_MSP-AU~MS609-0001
  MS609-0003~ok~0003~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~MS609-0001~1245-05-27~Hugo_de_Mamiros_MSP-AU~MS609-0001
  </code></pre>
  
  <p>I get the above serialized results in another function that should store it in the directory <code>/db/apps/deheresi/documents</code> as a flatfile <code>depositions.txt</code></p>
  
  <pre><code>let $x := schedule:deposition-textfile()
  
  return xmldb:store(concat($globalvar:URIdb,"documents"), "deposition.txt", $x)
  </code></pre>
  
  <p>But when I execute the <code>xmldb:store</code> action, it returns an error:</p>
  
  <pre><code>Description: err:XPTY0004 checking function parameter 3 
  in call xmldb:store(untyped-value-check[xs:string, 
  concat("/db/apps/deheresi/", "documents")], "depositions.txt", $x): 
  
  XPTY0004: The actual cardinality for parameter 3 does not 
  match the cardinality declared in the function's signature: 
  xmldb:store($collection-uri as xs:string, 
  $resource-name as xs:string?, 
  $contents as item()) xs:string?. 
  
  Expected cardinality: exactly one, got 710. 
  </code></pre>
  
  <p>How do I get these serialized results into the text file?</p>
  
  <p>Thanks in advance.</p>
  
  <p>UPDATE: I tried wrapping the serialized output in <code>&lt;result&gt;</code> and that fixes the problem of cardinality, BUT it writes the <code>&lt;result&gt;</code> element to the file as plain text:</p>
  
  <pre><code>&lt;result&gt;MS609-0001~ok~0001~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~self~1245-05-27~Arnald_Garnier_MSP-AU~self
  MS609-0002~ok~0002~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~MS609-0001~1245-05-27~Guilhem_de_Rosengue_MSP-AU~MS609-0001
  MS609-0003~ok~0003~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~MS609-0001~1245-05-27~Hugo_de_Mamiros_MSP-AU~MS609-0001&lt;/result&gt;
  </code></pre>
  
  <p>Even if I add: </p>
  
  <pre><code>declare option exist:serialize "method=text";
  </code></pre>