4.4. CSV comma-separated values

Let's have the data below in comma-separated values (CSV) format.

Note that the first row of data contains the column names in the following rows.

Also note that some values are not included in the row (e.g., an email address or phone number may be omitted). Only the data in the column name (the first column) is required.


Name, Email Address, Mobile Number
John Smith, john.smith@smith.com, +1 2345 67 89 01
, nobody@somewhere.org, +89 987 654 321
Somebody, ,
, , 98765412
Pamela Green, pamela-G@data.org, +49 123 456 789
Mary Green, mg@data.org, +49 1234 567 890
The first line of CSV data contains names of columns of data items. Model of CSV data is described as array of JSON/XON values:
<xd:def xmlns:xd="http://www.xdef.org/xdef/4.2" name="Example" root="test">
  <xd:xon name="test">
    [
      # header line:
      ["occurs 3 string(); /*three column names*/"],
      # CSV lines:
      [ %script="*",
        "required string()", "optional emailAddr", "optional telephone()"
      ]
    ]
  </xd:xon>
</xd:def>
You can try it HERE