~zorba-coders/zorba/bug-1189785-csv

« back to all changes in this revision

Viewing changes to test/Queries/converters/csv/txt_serialize4.xq

  • Committer: mbrantner
  • Date: 2011-08-17 23:28:43 UTC
  • Revision ID: svn-v4:8046edc3-af21-0410-8661-ec7318497eea:modules/data-converters/trunk:11722
- file module in no xqdoc category
- added missing break/continue in flwor statements to the known issues file
- documentation/error fixes for the csv module (provided by Daniel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
(: Serialize some nodes to text with fixed size columns.
2
 
The first line is the header.
3
 
Note that the last xml node doesn't have the same elements as the first node, 
4
 
so it is ignored.
5
 
Also note the truncation of fields.
6
 
 :)
7
 
 
8
 
import schema namespace csv-options="http://www.zorba-xquery.com/modules/converters/csv-options";
9
 
import module namespace csv = "http://www.zorba-xquery.com/modules/converters/csv";
10
 
 
11
 
csv:serialize(
12
 
(<row1>
13
 
  <f1>value1</f1>
14
 
  <f2>"value2"</f2>
15
 
  <f3>value3&amp;,value33</f3>
16
 
  <f4>value4</f4>
17
 
</row1>,
18
 
<row2>
19
 
  <f1>value11</f1>
20
 
  <f2>value12</f2>
21
 
  <f3>value13</f3>
22
 
  <f33>value13</f33>
23
 
  <f4>value14</f4>
24
 
</row2>,
25
 
<row3>
26
 
  <f11>value21</f11>
27
 
  <f22>value22</f22>
28
 
  <f33>value23</f33>
29
 
  <f44>value24</f44>
30
 
</row3>), 
31
 
 
32
 
validate{
33
 
<csv-options:options>
34
 
  <first-row-is-header/>
35
 
  <column-widths>
36
 
    <column-width>10</column-width>
37
 
    <column-width>7</column-width>
38
 
    <column-width>10</column-width>
39
 
    <column-width>7</column-width>
40
 
  </column-widths>
41
 
</csv-options:options>   }
42
 
)
43