rustxform-reader
The reading stage of the rustxform
pipeline: turn an XLSForm source into a raw Workbook
of string rows, before any semantic interpretation.
┌────────┐ ┌───────┐ ┌───────┐
XLSForm ──▶│ reader │──▶│ parse │──▶│ xform │──▶ XForm XML
└────────┘ └───────┘ └───────┘
▸▸ Workbook ◂◂ Survey XForm
Inputs
| Function | Input | Notes |
|---|---|---|
read_markdown(&str) |
Markdown tables | First column selects the sheet (see below). Infallible. |
read_csv(&str) |
CSV text | Same sheet convention as Markdown. |
read_xlsx(&[u8]) |
XLSX/XLS bytes | Each worksheet maps directly to a Sheet (via calamine). |
All three return Result<Workbook, ReadError> for a uniform API.
A Workbook is just { sheets: Vec<Sheet> }, and a Sheet is
{ name: String, rows: Vec<Vec<String>> }. Use Workbook::sheet(name) to look
one up.
The "first column selects the sheet" convention
For Markdown and CSV, a row whose first cell is non-empty opens a new sheet;
rows whose first cell is empty append their remaining cells to the current
sheet. Markdown separator rows (|---|) are skipped.
| survey | | | |
| | type | name | label |
| | text | q1 | Question |
| settings | | |
| | form_title | form_id |
| | Demo | demo |
Example
use read_markdown;
let wb = read_markdown.unwrap;
let survey = wb.sheet.unwrap;
assert_eq!;
assert_eq!;
Note
Internal building block of the rustxform workspace. For end-to-end XLSForm →
XForm compilation, use the top-level
rustxform crate.
License
Licensed under either of Apache-2.0 or MIT at your option.