Data workflow examples

Choose a workflow by its output. pyxsd validates and binds XML; your application decides how to aggregate values, join reference data, or apply business policy. See Optional Pydantic and Arrow integrations for conversion rules and supported shapes. Each family README supplies runnable commands, expected results, and sample-specific limitations.

Choose a workflow

Task

Example

Result

Validate Python input or read typed order snapshots

Purchase-order models

Pydantic models, JSON Schema, explicit presence

Load XML without a schema or keep native JSON

Schemaless XML and native JSON

Lexical XML tree, native XDM, explicit XML projection

Apply approval rules after XML validation

Order assessment

Exact subtotals and reason codes

Extract nested XML records or scalar columns

Arrow and Parquet

Typed tables, record batches, Parquet

Aggregate observations and join station metadata

DuckDB and Polars

Grouped totals, child expansion, Parquet readback

Validate or export several XML files

Sequential multi-document parsing

Per-file outcomes or a manifested dataset

Convert clinical documents or diagnose imperfect input

Healthcare

Scoped FHIR XML and source-specific diagnostics

Prerequisites

These examples require a repository checkout; a package installation alone does not supply the input files or scripts. Each family documents its optional extras and consumer dependencies. Install only what that workflow needs. With uv sync, name all groups you intend to keep: synchronization removes groups omitted from the command.

Choose the record shape before analysis

Nested Arrow records preserve child structs and lists. Scalar columns can carry parent context into one analytical row. Choose the declaration from the schema, then select its occurrences in the document; do not infer a table from the first dictionary row. See Optional Pydantic and Arrow integrations for declaration paths and FieldSource columns.

Expand child lists separately from parent totals to avoid multiplying measures. Keep identifiers and temporal values in their exact exported forms until your application explicitly chooses a numeric width, timezone, and precision. DuckDB/Polars compatibility is narrower than Arrow’s type system; the analytics example checks its consumer profile before querying.

The analytics README contains both consumer walkthroughs and their expected outputs.

The purchase-order README contains approval thresholds, rejection cases, and the assessment commands.

Check validity and application policy separately

Revalidate edited documents before conversion. A Pydantic snapshot is independent of its XML source; changing it does not update XML. An Arrow table is a data export, not a lossless XML representation. Output batching limits projected rows, not parser memory: each XML document is still materialized as a tree.

Malformed XML, XSD findings, unsupported adapter shapes, and business rejection are different failures. Report them separately so an invalid document cannot appear to be a valid order rejected only by policy. Base healthcare XSD validity also does not establish clinical, terminology, template, or profile conformance.

Library and application responsibilities

pyxsd handles schema interpretation, supported validation checks, and typed conversion. SQL/dataframe execution, joins, catalog ownership, exchange rates, and approval rules belong to the application. Keeping those responsibilities separate lets each example state which checks it actually performs.