Content of csv_serialize3.xq example

(: Serialize xml nodes to csv, with header and escaping some fields. :)
import schema namespace csv-options="http://zorba.io/modules/csv-options";
import module namespace csv = "http://zorba.io/modules/csv";

csv:serialize(
(<row1>
  <f1>value1</f1>
  <f2>"value2"</f2>
  <f3>value3,value33</f3>
  <f4>value4</f4>
</row1>,
<row2>
  <f1>value11</f1>
  <f2>value12</f2>
  <f3>value13</f3>
  <f33>value13</f33>
  <f4>value14</f4>
</row2>,
<row3>
  <f11>value21</f11>
  <f22>value22</f22>
  <f33>value23</f33>
  <f44>value24</f44>
</row3>),
validate{
<csv-options:options>
  <first-row-is-header ignore-foreign-input="true"/>
  <csv separator=","
       quote-char="""
       quote-escape=""""/>
</csv-options:options>}
)