Getting started
Schemantix is an editor for schemas — JSON Schema (draft-04, draft-06, draft-07, 2019-09 and 2020-12, written in JSON or YAML), XML Schema (XSD 1.0 and 1.1), OpenAPI (2.0 — Swagger —, 3.0, 3.1 and 3.2) and record schemas for CSV, fixed-position and COBOL files. You can work on a schema as text and as an interactive diagram; both show the same document. It can also generate example data from a schema.
Everything runs in your browser. Documents are not uploaded anywhere; see “Your data and privacy”.
Start from a sample
A new workspace opens on one question: drop a sample file here. Drop a JSON, YAML, XML, CSV or fixed-width file on it — or several of one kind — or click Choose a sample…, and you get a proposed schema on its diagram, the sample paired with it, and three examples of the schema in a strip under the diagram. Keep as data document keeps one; × puts the strip away. For JSON, YAML and XML the proposal itself stands in the second window, beside the diagram: it says per place in how many documents it was seen and marks with ? where it is still guessing (see “Proposing a schema from data”) — and so does the diagram, on the card of each such place, for as long as the schema is as the proposal wrote it (the tooltip says why; an edit to the schema puts the marks away, and Open as schema brings them back). A CSV or fixed-width file proposes a record schema. Start blank puts the page away and leaves a new, empty schema to write in — named in your language (untitled.json, in Dutch naamloos.json). Until then nothing of yours is open: no tab, nothing in the status bar, and nothing added to the recent files. The page also offers example workspaces to copy from — Payments, An insurance policy message and An order file — each with its schemas, data documents, a pipeline and the tests of both, every one passing; one opens in a folder of its own, its main schema shown and each data document paired with its schema, so it is checked as you type, to be changed into your own. On the command line, schemantix example lists them and schemantix example payments --out <folder> writes one. The page comes back whenever you have closed everything; a workspace you come back to opens as you left it.
Your first schema
- Open a schema with File › Open… — or drag it onto the window — or start a new one with File › New….
- The document opens in its own tab. In the Text view you type the schema; press Ctrl+Space for suggestions of what may be written where you are.
- Switch to the Diagram tab below the editor to see the structure. Pick a starting point, then expand cards with their + button.
- Problems appear in the Problems panel at the bottom — while you type, and whenever you switch views. With nothing to report the panel is folded to one bar, its tabs and the count of problems; it opens by itself when a problem arrives, and the arrow at the end of its bar opens and folds it, at the height you last dragged it to.
- Every panel folds the same way: the arrow at the end of its head points to the edge it folds to — the sidebar on the left, Node details on the right, the panel below. Folded, a side panel is a strip with its name, which opens it again; the panel below keeps its bar. Which ones you folded is remembered.
- Save your work with File › Download (Ctrl+S). Your work is also kept in the browser in case you close the tab by accident.
Every setting is under Settings at the top right, in two dialogs: Display (the language — your browser’s, where it is English or Dutch, until you choose — the Theme — light, dark, or as your system has it, which is where it starts — Plain words, Boxes around definitions and Diagrams from top to bottom) and Advanced settings, on four tabs down its left side by what they are about: Queries and transformations (how long a query or a transformation may take, and XSLT: streaming — what a part of a stylesheet that asks to be streamed gets where the rules do not guarantee it can be: strict, the default, extended or off — and XSLT and pipelines: validating the document first — strict, the default, or lax), Record files (how many records the grid and the diagram edit in place — left empty, this edition’s own number; a larger file is shown there and edited in its text — whether a copybook’s REDEFINES keeps its first reading, which format a copybook’s floating-point numbers are in, and the root element a record file’s XML is wrapped in), JSON and YAML (whether a check of JSON data also judges contentEncoding and contentMediaType, whether YAML data is read with merge keys (<<), and whether a YAML conversion is — on unless you turn it off) and XML (three choices for reading XML data: which edition of XML 1.0 decides names, reading without Namespaces in XML, and reporting optional errors). The arrow keys move between the tabs, and the dialog opens on the tab you last used. Each setting says underneath what it does, and a change applies as you make it — the dialog has one button and it closes. Diagrams from top to bottom lays every diagram out downwards instead of from left to right (see “The diagram”). Boxes around definitions draws a box around the content that comes from a named definition, with its name above it, the way XMLSpy draws a referenced type — so you can see where a definition begins and ends without following every line. The box says something about the cards inside it and is not a card itself: it has no actions of its own, so right-click a card to act on a definition. It follows the theme, and the choice is remembered. This guide is available in each language.
The screen
- Toolbar (top): the menus File (new, open, download), Schema (other versions and formats, merging), Data, Transformations and Documentation (the HTML page and the diagram exports), the search field (Ctrl+F or Ctrl+K), Undo and Redo as two arrows — hold the pointer over one to read which — and Lay out, all three always in their place: where one does not apply it is greyed out and says why (in the text, the editor keeps its own history, Ctrl+Z; in a diagram there is no text to lay out). Undo and redo work when an edit has made an error and the diagram is locked, as do Ctrl+Z and Ctrl+Y, also while the focus is still in the dropdown or field the edit was made in; on the right Settings (every preference, in two dialogs, and the Focus and the Role, each a submenu — see “Focus: a workplace for each kind of work”; a focus may put a menu or some of its entries behind More ▾) and Help (the user guide, and Licence…, which says which licence Schemantix runs under).
- On the left (always): the lists Schemas, Data files, Pipelines, Tests, Stylesheets, Generator profiles and Schema proposals of the workspace — in each, a folder is named once as a heading with the bare names under it; the whole path is the tooltip — Referenced, not available for referenced documents that are missing, and — in the diagram of a schema — the Start points; for an OpenAPI document also its Operations, each with what it sends and receives. Click a heading to fold its list away (and back); the app remembers it. Above the lists, two tabs: Workspace shows them by kind; Projects shows the documents that belong together — a schema with the schemas it refers to, its data documents, test files, generator profiles, pipelines, templates and answers files, proposals and stylesheets — each marked by its kind (hold the pointer over the mark to read which). A project starts at its main schema: the one from which the most of it can be reached. Every document is in one project only; documents tied to nothing stand under Loose documents. Choose a project in the list at the top to show its first document; while Projects is chosen, the tabs above the editor show only that project’s documents. Nothing has to be set up — these are the ties the workspace already knows — but you can change them: × takes a document out of the project, Add a document… moves one in (a stylesheet to the XML it runs over, say), and Close project… closes all of it, saying first which documents have changes not yet saved. The tab and your changes are kept with the workspace.
- Tabs above the editor: one per open document, data document ({} or ‹›), generator profile (⚙) or schema proposal (◇). A dot marks changes that were not downloaded; + opens a new document, data document or profile.
- Editor area: the text editor, the diagram or the profile editor. The Text and Diagram tabs below it switch views. Each document remembers which view it was shown in — a data document its own Text, Diagram and Grid — so a tab comes back the way you left it rather than the way the tab before it was showing, the next time you open Schemantix as well; a schema you have not shown yet opens on its diagram.
- Node details (right, in the diagram): one sentence in plain language about the selected node, and an example of what may stand there; its Name, Type and Description to change right beneath, and everything else you edit it with below a fold. Where the schema has a sample, a field’s example is the sample’s own value. The diagram shows the same example after each field’s type: a value made up for the field and checked against the schema, which follows every change to its restrictions — and turns red where no value can meet them all (say, a minimum length above the maximum). Drag its left edge to make it wider or narrower, as with Schemas on the left; the width is remembered. The arrow beside its title folds it to a strip at the edge, which gives the diagram the room; the strip opens it again, and so does choosing a node. On a window narrower than 1280 px it starts folded.
- Problems (bottom): errors and warnings of the active document; next to it, Query searches and calculates in the document (see “Searching and calculating”), Tests runs a test file of the schema (see “Declared tests”), and — where they apply — the Debugger of a transformation, the Ruler of a record file and the Layer of a layer. The line between the editor and this panel, and the one next to the lists on the left, can be dragged.
- Status bar (very bottom): whether the document is valid, its format and version, and whether everything has been downloaded; for a data document whether it is well-formed or valid, JSON or XML, and the schema it is checked against.
Focus: a workplace for each kind of work
Schemantix does a great deal, and most work needs only part of it. A focus arranges the application for one kind of work: which panels stand below the editor and in which order, which view a document opens in first, which entries stand in the menus, which examples the start page offers first and which chapter of this guide opens first. Nothing is taken away: what a focus leaves out is one More ▾ further — at the end of a menu, after the panel tabs, or in the toolbar for a whole menu.
Choosing one
- Focus (under Settings, with Role below it): All is the whole application, as it has always been; Record files puts the grid, the Ruler, Problems and Tests first; Schema design puts the diagram, Problems, Rules and Tests first, with transformations behind More ▾.
- Role (beside it): Developer keeps Query and the Debugger among the panels; Analyst puts names and explanations first, with Query, the Debugger and transformations behind More ▾; Tester puts Tests first, with Query beside them and every way to make and check data in the Data menu. A role changes every focus except All.
- When you open a document that fits another focus — a record file, say — a bar above the editor asks whether to switch. It never switches by itself, and each focus is proposed once; Don’t ask again stops the proposals altogether.
Making one your own
- Focus › Adjust… shows tick boxes for the panels and for each group of each menu, and which view a document opens in first. Keep keeps what you ticked for this focus in this role; Back to default lets it go.
- Focus › Keep for the project … makes the project of the document shown keep its own focus and role: whenever one of its documents is shown, they are the ones in force, and choosing another changes the project’s. In Adjust…, Only for the project … keeps an adjustment for that project alone.
- Your choice is remembered, the next time you open Schemantix as well. A focus is a small file of settings, so the arrangements can grow with the work; packs for message standards will bring focuses of their own.
Documents, tabs and workspaces
Opening and saving
- File › New… is the one place to make anything: on the left the category — Schema, Data, Transformation, Generator profile, Test file, Schema template (wizard) — and on the right the kind, chosen from a list (type its first letters to jump to it), then Start from where the kind can begin in more than one way (nothing but the start, or an example), and what may be chosen for it. The likeliest choice is already made, so most of the time you only press Create. A version you choose is kept even where the text cannot say it, as in a GraphQL or Avro schema; a SQL script starts with its dialect’s own words, so it is known for that dialect when you open it again. A schema of any format and version — a JSON Schema written as JSON or YAML, an OpenAPI document empty or with an example to start from —, a record schema of delimited fields (CSV, with its delimiter, header line and encoding) or of fixed width, one proposed from sample data, or one read from a COBOL copybook in the encoding its files are in; data as an example for a schema, as empty XML (version and encoding), JSON, YAML or plain text, or a CSV or fixed-width file made together with its schema; an XSLT stylesheet of version 1.0, 2.0 or 3.0, or a transformation pipeline from documents of one schema to documents of another; a generator profile or a template for the schema you choose — one of the workspace, or one picked with Choose a file…. Name says what it is called, filled in for you.
- File › Open… opens one or more files — or a zip archive; File › Open folder… opens every schema, data file, generator profile and schema proposal in a folder (other files are skipped). You can also drag files, folders or zip archives onto the window, the text included: while you drag, the window shows where to drop, and they open as tabs, just the same.
- Files in any encoding open. A document is read in the encoding it says it is in — the
encodingof its XML declaration, or a byte-order mark where it has one — so files in UTF-8, UTF-16, Latin-1, Latin-9, Windows-1252 and the EBCDIC pages open as themselves. An encoding the browser has no table for — Shift_JIS, GBK, Big5 — is not read as itself: the file is read in the page its bytes look most like, with a notice that the reading is a guess. Where the bytes and the declaration disagree about which encoding it is, XML calls that an error and the file is not read: that is a corrupted file, and guessing would hide it. - File › Recent files reopens a document you had open before.
- In the desktop edition with a licence the workspace is a folder on disk. File › Open folder… opens one with the system’s own dialog, and the application reads and writes inside that folder only; File › Recent folders opens one again. File › Save writes each document back to its file, and Save as… and every export (a diagram, the documentation, a converted copy, a zip, generated examples) go through the system’s save dialog — a copy of the document in another version included, which leaves it marked unsaved, since its own file still holds what it held. When another program changes a file you have open, a document without changes of yours is read again (the status bar says so), and one with changes asks: Keep mine or Reload. Closing the window while something is unsaved asks Save, Close without saving or Cancel, and the title bar marks unsaved work with a dot. A transformation can write its result straight to a file (Write the result to a file…), which suits a result too large to open. File › Open… uses the system’s own dialog too: a file inside the folder open joins under its path there and is saved back to it, and a file from anywhere else is saved through the save dialog — never into the folder, even where the folder holds a file of the same name. A file removed on disk by another program is not closed: its document is kept and marked unsaved, the status bar says so, and saving it writes the file back. A folder of more than 5 000 files opens its first 5 000, and the status bar says so. When the application starts again with the work it kept, the folder comes back with it — if it is still on the recent list and still there — so its documents save to their files again; a document whose file changed meanwhile is read again, and one whose file is gone is marked as above. Without a licence the desktop edition works as the browser edition does: Download, and a folder opened the browser’s way.
- Installing the desktop edition: run Schemantix_…_x64-setup.exe. It installs for you alone, in your own profile, and asks for no administrator rights; it brings Microsoft Edge WebView2 with it where Windows does not already have it. Uninstall it under Settings › Apps; your licence (in
%APPDATA%\Schemantix) stays where it is. While the installer is not yet signed, Windows SmartScreen may say *Windows protected your PC*: choose More info, check that the file is the one you were given, and then Run anyway. The application does not update itself yet: install a newer version over the old one. - On Linux there are three packages of the same application: Schemantix_…_amd64.deb for Debian and Ubuntu (
sudo apt install ./Schemantix_…_amd64.deb), Schemantix-…x86_64.rpm for Fedora, Red Hat and openSUSE (sudo dnf install ./Schemantix-…x86_64.rpm), and Schemantix_…_amd64.AppImage, which needs no installing: make it executable (chmod +x) and start it. They run on Ubuntu 22.04, Debian 12, Fedora 36 and what came after them; the .deb and the .rpm use the system’s own WebKitGTK, the AppImage brings its own. Your licence is in~/.config/schemantix. - File › Download (Ctrl+S) saves the document shown. A schema that refers to or includes other documents of the workspace is saved together with them as a zip, with their folders, so the references between them still work; a data document, generator profile or schema proposal is saved as itself. Download all (.zip) (with more than one document open) saves every document of the workspace, data documents, generator profiles and schema proposals included.
- Schema › Other version (download or convert)… converts the document to another version (see “Versions”), or to another format. Every format is offered that the document can sensibly become, also where the way there goes through another format, as Avro to XML Schema goes through JSON Schema; what any step could not carry is told in the notes. Only what would say nothing is left out: a WSDL or AsyncAPI document made from a schema with no operations in it, and anything to or from Schematron.
- Documentation › HTML documentation (.html) downloads a readable page about the schema — together with the documents it refers to or includes: for the root and every definition its description, type, restrictions, default and examples, what it contains (with how often, and which parts are required) and where it is used. References are links, also between the documents. Each entry opens with the same sentence in plain language that Node details opens with, and the standard’s constructs are named as Plain words says. The page is in the language of the application and prints well; it is offered for a schema that can be read, not for a data document. The command line writes the same page:
schemantix document order.xsd --out order.html, with--lang nlfor Dutch and--plainfor plain words. - In the diagram, Documentation › Export diagram as … saves what is expanded as a Mermaid flowchart (.mmd) or a vector image (.svg). On the command line,
schemantix diagram <schema>writes the same file with everything expanded —--to svgfor the image,--startand--depthto draw less,--plainfor Plain words,--direction downfor a diagram from top to bottom. - Documentation › Export diagram to explore (.html) saves the diagram as one page for someone who does not have Schemantix: it opens in any browser, also offline. Every card is in it, and the cards you had closed are closed there too. Click the + on a card to open it and the − to close it — the rest moves aside, as here; click a card to see its kind, how often it occurs, its type, restrictions and note beside the diagram; type a name under Find a card to open the way to it; zoom with the mouse wheel or the buttons, drag to move, and Fit to see it whole. Export diagram to explore as SVG (.svg) saves the same as an image that does all this where a browser opens it, and shows the diagram as it was when you saved it where it is put in a page as an image (a wiki, Word, a README). The page’s words are in the language of the application. On the command line:
schemantix diagram <schema> --to html(or--to interactive-svg), with--depthfor how deep it is open.
Tabs
Paste into a new document and it becomes what you pasted. Make a new document — a schema or a data document — and paste an XML Schema, a JSON Schema, a stylesheet, JSON, XML or YAML data, or a CSV into it: it is recognised and becomes that kind of document, renamed to match (untitled.xsd, untitled.xsl, untitled.yaml, untitled.txt, and a JSON Schema written in YAML untitled.schema.yaml), and the status bar says what it was taken for. This happens only in a new document, whose name Schemantix made, and only when you paste — not while you type, when text is half-written.
Every open document is a tab. Each tab, and each document in the sidebar’s lists, carries the mark of its kind: a schema ◫, data {} (‹› for XML, ≡ for plain text), a test file ✓ and proposed tests ☑, a pipeline ⇶, a stylesheet ⇥, a query ?, a generator profile ⚙, a schema proposal ◇, a template ⧉ and an answers file ✎. The mark is coloured by its kind’s family — schemas, data, tests, pipelines, transformations, generator profiles, templates — and a tab’s left edge has the same colour; point at the mark to read the kind in words. The tabs stand on one row: when there are more than fit, the arrows either side of them scroll the row — each is active only while a tab is out of sight on its side — and so does the mouse wheel over the row; the tab you show is always scrolled into view, and the + stays beside them. Click a tab to show it and × to close it; you are asked first when it has changes that were not downloaded. Closing the tab that is showing shows the one to its left, or the one to its right where it was the first, so the row stays where it was. A schema can be closed while data documents, generator profiles or schema proposals are open: a workspace does not need a schema. Only when the last document of all is closed does a new, empty one appear; and a new, untouched document gives way to the first documents you open. + in the tab bar opens File › New… at the kind of document shown. The tabs stand in the order you opened the documents in, the newest at the end, and you can drag a tab to put it where you want it — dropped on another tab it takes that tab’s place. The order is remembered with the workspace, so it comes back as you left it. The tab you were on is the tab you come back to: opening Schemantix again shows that document — a schema, a data document, a generator profile, a schema proposal or a stylesheet — on the view you had it on. If it is no longer there, because you opened another folder or removed it, the schema shows and nothing is lost.
The editor area can be split in two: right-click a tab and Show in the other window, or drag the tab onto the other window’s strip, and you have two windows side by side, each with its own tabs. A document stands in exactly one of them — dragging its tab moves it — and the window you last clicked in is the one a new document opens in and the one the panels below describe. Drag the edge between them to share the width; move the last tab out of the second window and it closes again — or click ✕ at the end of its tab strip, and its tabs all go back to the first window. Two schemas side by side: the window you are working in shows its schema as you left it — text or diagram — and the other shows its text, as it stood when you last looked away, with the findings it had then. Type in it and it becomes the window you are working in, so what you type lands where you typed it. The diagram is always the window you are working in: a diagram carries a selection, a viewport, an undo history and a lock, and those belong to the one schema being edited. A data document, a stylesheet, a generator profile or a schema proposal can stand in either window and is edited in both. Right-click a tab to close more than one document at once:Right-click a tab to close more than one document at once: Close, Close all, Close all but this one and Close everything unrelated to this one. Each of the last three first says how many documents it will close and lists them by name, with a dot on every one that has changes you did not download and a line saying how many those are; cancel and nothing happens at all. Close all leaves one new, empty document behind, just as closing the last tab by hand does; the other two leave the document you right-clicked open and in front of you. An action that would close nothing is shown greyed.
A document belongs with another when Schemantix knows of a connection between them, and that counts both ways and through as many steps as it takes: a schema that refers to, imports or includes another schema (and the schema *that* one imports), a data document and the schema it is checked against, a stylesheet and the stylesheets it imports or includes, a stylesheet and the document of the transformation you are stepping through, a generator profile and its schema, a schema proposal and the data documents it was proposed from, and a pipeline, test file, proposed tests, template or answers file and what it names. These same connections make the Projects tab of the sidebar, where you can also add a connection Schemantix does not know of yourself. Nothing else counts: documents are not connected by lying in the same folder or by having similar names, and a stylesheet is not connected to every document it *could* be run over. So the result of a transformation counts as unrelated to the stylesheet that made it — nothing records where a result came from — which is why its dot and the list are there before anything is closed.
Workspaces
Documents opened together form a workspace: references between them resolve and are followed in the diagram — JSON Schema $ref to another file, and XSD xs:include, xs:import, xs:redefine and xs:override. A card from another document shows that document’s name; double-click it to open it there.
- Referenced documents that are not in the workspace are listed under Referenced, not available. A web document can be loaded with Load — only when you ask, it is never fetched by itself; some sites do not allow it, and documents over 5 MB are refused.
- References with an absolute file path or a web address get a warning with a one-click fix to a relative location when that document is in the workspace.
Comparing two schemas
Schema › Compare with another schema… sets the schema shown against another of the workspace — two versions of one, or two of one subject, in the same format or not. They are compared by what they are and not by their text: each place a document of either can hold is matched by its names on the way down, so a definition moved, a reordering or another layout is no difference. Listed are the places only in the first (−), only in the second (+) and changed (~, with what changed), then the definitions only in one, changed, or renamed (>: the same content under another name). Show what is the same too lists the rest (=).
Files that use it, below, lists each pipeline and test file of the workspace that names the schema shown, with the places it names that the change removed (−) or changed (~) — a place whose documentation alone changed bears on nothing. A file that uses the schema and names nothing that changed says so. On the command line, schemantix diff a b --impact <folder> does the same for the pipelines and test files of a folder and its subfolders.
Show in the diagram draws the comparison in the diagram of the schema shown: each card is marked as only here (dashed), only in the other (drawn from the other schema, read-only), changed (with what changed in the inspector, under Compared with …) or the same. The bar above the diagram shows only the differences and the cards that lead to them, only what the two share, or everything; End the comparison draws the schema alone again.
Data › Compare with another document… compares the data document shown with another XML, JSON or YAML document of the workspace by their trees: each value only in one (+, −) or changed (~, with what each has), by its path (order/line[2]/@id, counted from 1). An XML document is read as the XML mapping writes it — @ before an attribute — so two documents of different syntaxes compare by what they hold, and an item put into a list moves nothing after it. Their texts are shown line by line beside it.
On the command line: schemantix diff v1.xsd v2.xsd writes the same lines, and --json the whole comparison; it leaves with 1 where the two differ, as diff does. Two data documents are compared the same way: schemantix diff a.json b.json, with --text for their texts line by line. And schemantix diagram a.xsd --compare b.xsd writes the compared diagram as Mermaid or SVG (--show differences, common or all).
Merging a set into one schema
Merge schemas (Schema › Merge schemas…, or in the workspace panel under the list of schemas) folds everything the schema shown includes or refers to into it, so that the result can be given to something that reads one file. The dialog shows what it would make — which documents, and out of how many — before anything is opened; nothing changes until you press Merge, and what it makes then opens as new tabs you can look at and download.
For an XSD the dialog asks what is to become of the namespaces, because an xs:schema element carries exactly one targetNamespace and so one document can never hold two namespaces’ worth of definitions:
- Keep the namespaces (the usual choice) folds in the includes and leaves an
xs:importstanding, pointing at the merged document of that namespace. You get one document per namespace, and together they accept exactly the XML documents the set you started from accepts. - Everything in one namespace moves the imported definitions into the schema’s own namespace and rewrites every reference to them. You get a single document — but XML written in the other namespaces is then no longer valid against it, which is why the dialog says so before you choose it.
A JSON Schema has no target namespace, so there is nothing to choose: references into other documents are folded in under $defs and the pointers rewritten. An XML Schema without a target namespace has the choice as soon as it imports one.
When anything is wrong, nothing is merged and the dialog lists everything it found at once, so you can put it all right in one go. The usual ones: two documents that declare the same name and do not mean the same thing by it (see below), two that declare the same $anchor in different places, an xs:redefine or xs:override (these change what they bring in, and merging does not do that yet), a document that is not in the workspace, or two documents that write the same prefix in an XPath meaning different namespaces.
Under a clash the dialog offers the fix. It proposes a new name for one of the two definitions — the second, named after its document’s first element or its file name (Polis_Address); choose the other document to rename the first instead, and change the name if you like. Rename in the merged result is the usual choice: only the merged document gets the new name, and what refers to the definition there follows it, while your own documents stay exactly as they are. The rename is listed above the findings, with Undo. Rename in my documents too renames the definition where it is declared and everything in the workspace that refers to it, as Rename in the diagram does, and asks the merge again; the documents it changed are marked as changes to save.
Definitions that differ only in their description are one. Two documents may declare the same type alike and describe it differently — another title, another description or xs:documentation, another comment, here or in one of its parts. That is no clash: the result has the definition once, with every description, each once, and a warning says so. Choose a document under the warning to keep only its description.
What the merge did anyway is listed too: a document written for an older version is translated into the version the result is written in, and a document whose elementFormDefault or attributeFormDefault differs from the result’s has its local declarations written out with an explicit form, so they keep meaning exactly what they meant.
Schemas written in YAML
A JSON Schema may be written in YAML as well as in JSON. A YAML file is a schema only by a mark: its $schema names a version of JSON Schema ($schema: https://json-schema.org/draft/2020-12/schema), or its name ends in .schema.yaml or .schema.yml. Any other YAML file is data, however much it looks like a schema. A schema in YAML is checked, drawn and edited as one in JSON is: a finding is underlined where it stands, Ctrl+Space suggests the keywords and values allowed at the indentation you are at, Ctrl/Cmd-click on a $ref goes to what it names, and an edit in the diagram writes the text back in YAML.
An edit in the diagram writes the whole text again, in Schemantix’s own order of keywords, with short lists on one line (required: [id, name]) and texts of several lines as a | block. Your `#` comments are kept: each one belongs to the property or keyword it stands with — above it, at the end of its line, or at the start or the end of what it holds — so it moves with a property you rename or move and goes with a property you delete. A comment about a keyword you take away stays, at the end of its schema. Anchors and aliases (&name, *name) are written out in full, and the Problems panel says so when the file is read. A --- line at the top, and the %YAML and %TAG lines above it, are written back as they were.
Schema › Write as YAML (or Write as JSON) opens the schema written in the other syntax beside it, as name.schema.yaml or name.schema.json. JSON has no comments, so the JSON copy has none; the YAML document keeps its own. File › New… › Schema offers Written as: JSON or YAML for a JSON Schema. On the command line every command that writes a schema keeps the syntax it read and takes --syntax json or --syntax yaml to choose: schemantix convert person.schema.json --to json-schema --syntax yaml. There a YAML file that a $ref names and that says nothing about itself — a pet.yaml with no $schema — is read as a schema of the same version as the file that refers to it.
OpenAPI documents
An OpenAPI document — version 2.0 (Swagger), 3.0, 3.1 or 3.2 — describes an HTTP interface — its paths, the operations on them and what each sends and receives — and holds the JSON Schemas of those payloads. It may be written in JSON or in YAML, and is one by its mark: openapi: at its top (or "openapi" in JSON), or a name ending in .openapi.yaml or .openapi.json. Its version is the first two numbers of what openapi says (3.0.3 is 3.0) — or, for Swagger 2.0, what swagger says (swagger: "2.0"); a document that says another version, such as 3.3.0, is asked about, never guessed.
What differs between the versions is mostly in the schemas. In 3.0 a schema has one type, and says that null is allowed too with nullable: true beside it; exclusiveMinimum: true makes minimum exclusive; a schema has one example; and a keyword 3.0 does not have — const, if, $id, a word of your own — is an error, because 3.0 allows only its own keywords and x- extensions. In 3.1 and 3.2 a schema is JSON Schema 2020-12: type: [string, "null"], exclusiveMinimum: 0, examples, and every keyword of JSON Schema. 3.2 adds places for schemas to the document: the query method, additionalOperations, components/mediaTypes, itemSchema for each item of a stream, and encodings within encodings.
Swagger 2.0 is OpenAPI’s version 2.0, and is read, checked, drawn and written back as the others are. Its document is laid out differently: the schemas the others keep under components/schemas stand under definitions; a request body is a parameter with in: body and a schema; a response has its schema directly; the media types are said once, in consumes and produces, for the document or for an operation; and a parameter of another kind (in: query, path, header or formData) and a response header write their type, format, items and bounds in themselves, without a schema. Each of those is a message you can check data against and make examples of. Its schemas are a part of JSON Schema draft-04: allOf and no oneOf, anyOf or not; discriminator the name of a property, which must be a required property of the schema; readOnly, xml, externalDocs and one example; and type: file for a file. A response’s examples, by media type, are checked against its schema. The document is checked against the official 2.0 schema of the OpenAPI Initiative. A Swagger 2.0 document can be converted to a JSON Schema (draft-04), and through it to the formats JSON Schema converts to.
From Swagger 2.0 to OpenAPI 3 and back: Schema › Other version… writes a 2.0 document as 3.0, 3.1 or 3.2, and a 3.x document as 2.0 — on the command line schemantix convert api.yaml --to openapi@3.1 (or @2.0). The document is laid out again: host, basePath and schemes become servers and back (a server’s variables at their defaults); a body parameter becomes a requestBody for each media type the operation consumes, form parameters one form schema; a parameter’s own type and bounds move under schema, its collectionFormat becoming style and explode; a response’s schema and examples go into a content map per media type it produces; definitions become components/schemas, and security schemes are named in the other version’s words. A union 2.0 has no oneOf or anyOf for is written as 2.0 can say it — a list of types, or a schema with x-nullable: true for “this or null”, the word the 2.0 tools use, which becomes nullable in 3.0 and a null type in 3.1 on the way back. What 2.0 has no place for — a cookie parameter, a callback, a link, a webhook, a second server, a bearer token, a discriminator’s mapping, a union of schemas — is left out or written as it was, and counted in the status bar, the same list the command line gives. Any other format reaches 2.0 through OpenAPI 3.0.
Schema › Other version… writes the document as another version. From 3.0 to 3.1, nullable becomes a list of types, exclusiveMinimum: true a number and example one of examples, and nothing is lost. From 3.1 or 3.2 to 3.0, what 3.0 cannot say — two types, two examples, if, const beside enum, a webhook — is written as it was and marked when the converted document is read, so you see what to change; the status bar counts each thing that could not be carried, the same list the command line gives. On the command line: schemantix convert api.yaml --to openapi@3.0 (or @3.1, @3.2), which lists what could not be carried, and schemantix new openapi --version 3.0 for an empty document of that version.
Its schemas are checked, completed and drawn as a JSON Schema’s are. Each schema under components/schemas is a definition of its own name, and a $ref: '#/components/schemas/Pet' goes to it. Every other schema of the document — the body of a request, of a response, a parameter’s, a header’s, in paths, webhooks and components — is a message, named by where it stands (/paths/~1pets/post/requestBody/content/application~1json/schema, the way a $ref would name it). The diagram starts from any component or message. The rest of the document — info, the operations, the servers — is edited in the text: an edit in the diagram writes the text again with it exactly as it was, your comments included.
A message is called what a reader of the API calls it: its card says POST /orders · request body (application/json), GET /orders/{id} · 200 response (application/json) or, for a parameter every operation of a path shares, /orders/{id} (every operation) · id (path). The start points, the list on the left and Starts at list each message under its operation, by its part. Select a message, and the inspector says its operation, its part and its place in the document — the pointer a $ref and --start take. A message is named by where it stands, so it is not renamed in the diagram: move or rename the operation in the text, and the message follows. File › New offers an OpenAPI document empty, or with a small example to start from — two operations on orders with a request body, two responses and a path parameter — at any of the three versions, in JSON or YAML; on the command line, schemantix new openapi --kind example.
The document itself is checked against the official OpenAPI schema of its version, which the OpenAPI Initiative publishes and which comes with this build, so a missing info or a field the version has no place for (webhooks in 3.0) is reported where it stands. Besides that: an operationId used twice, a path such as /pets/{id} whose operation declares no parameter id in the path, and a $ref of a parameter, a response or an example that names nothing in the document.
Inside its schemas, a discriminator, an xml and an externalDocs are checked against the shapes the OpenAPI Initiative publishes for them: a discriminator needs a propertyName, external documents a url, and in 3.2 an xml with nodeType may not also say attribute or wrapped, which nodeType replaces. In 3.0 three more rules of its schemas are checked: a default must be of the type beside it (null only with nullable: true), a schema with type: array must say its items, and a schema may not be both readOnly and writeOnly. 3.1 and 3.2 have none of the three. A 3.2 document that says $self is known by it: the $refs of its schemas are read from there, and another document of the workspace may name it by its $self wherever the file is kept.
Its examples are checked too: the example, and each example under examples, of a request or response body, a parameter or a header is checked against the schema beside it, at the document’s version, and one that does not fit is a warning placed where in the example it does not fit — /id: the value is not of type integer. In 3.0 and 3.1 that is the example of a parameter, a header or a JSON body (application/json, or a media type ending in +json); an example of another media type, such as XML, is that media type’s own text and is not checked. In 3.2 an example’s dataValue is checked wherever it stands, and one that does not fit is an error, because 3.2 says it must be valid; its value and example are checked only for a JSON body. A serializedValue and an externalValue are not checked, and nothing is ever fetched.
Requests and responses: a property marked readOnly belongs in what the API sends, and one marked writeOnly in what it is sent. A data document checked against a request body, a parameter or a request’s header gets a warning for each readOnly property it holds, and one checked against a response or its header for each writeOnly one; the request body of a callback is a request like any other. In 3.0 a required property marked so may be left out where it does not belong, because 3.0 says its required counts in the other direction only; in 3.1 and 3.2 required stands, so a required property is not reported. An example made of a message leaves those properties out in the same way. A component checked on its own has no direction, and none of this applies to it.
Formats and choices: the formats OpenAPI names are checked — int32 and int64 as whole numbers in their range, float and double as numbers that fit in them, and in 3.0 byte as base64 — and a value that does not fit is a warning, as for any format; an example made of a message has values that fit. Where a body is one of several schemas (oneOf or anyOf) with a discriminator, an example made of it carries the property the discriminator names, with the value that names the schema chosen: its key under mapping, or else the component’s name.
A data document is checked against a message: choose it under Starts at, where each is listed under its operation (POST /orders › request body (application/json)) — a document of the API has no root of its own to start from, so where the API has more than one message, nothing is checked until you choose one. On the command line, where a list of places names each message by its pointer with its operation and part beside it: schemantix validate pet.json --schema api.yaml --start '/paths/~1pets/post/requestBody/content/application~1json/schema', schemantix generate api.yaml --start … for an example of that message, and schemantix convert api.yaml --to json-schema for the schemas as one JSON Schema, each component and each message a $defs entry. A bare pet.yaml that the document $refs is read as a schema of the document’s version: 3.0’s kind of schema for a 3.0 document, JSON Schema 2020-12 for 3.1 and 3.2.
Schemas in files of their own. A pet.yaml with nothing in it to say what it is — type: object and its properties — is a data file on its own. Open it with the document that refers to it ($ref: schemas/pet.yaml), or open that document later, and it becomes a schema of the document’s kind: 3.0’s for a 3.0 document, JSON Schema 2020-12 for 3.1 and 3.2. The files it refers to in turn become schemas too. Close the document, or take the $ref out of its text, and the file is data again; its tab stays where it was. A JSON Schema works the same way: a file of keywords alone that a draft-07 schema refers to is read as draft-07.
The operations of the API stand in the panel on the left while the diagram is shown, in the order the document writes them: GET /pets/{id} — Show a pet, with each operation’s summary, and marked when it is deprecated. Open one to see what it sends and receives — the parameters of its path and its own, its request body, its responses and their headers, also those it takes from components by a $ref — and choose one to show it in the diagram. With the keyboard: Tab to the list, the arrow keys, Home and End to move, Enter or Space to open or show. On the command line, schemantix operations api.yaml lists the same, each message with the pointer --start takes.
The keywords OpenAPI adds to a schema — discriminator, xml, externalDocs and example (and in 3.0 nullable) — have no field in the diagram. They are kept exactly as you wrote them, and you change them in the text. Select the schema and open Other in the inspector: they are listed with their values as keywords of the document’s version, apart from a keyword of another version (such as const in 3.0) and keywords of your own (x-internal). Ctrl+Space offers them in a 3.1 or 3.2 document.
A description in several files. A $ref of a path, a parameter, a response or the like may name another file — $ref: ./paths/pets.yaml, $ref: parameters.yaml#/limit. Open that file with the document (or as part of the folder) and it is read as a part of the description, at the document’s own version: it needs no openapi: or info of its own and is not asked for them. A $ref naming a place the file has not got is reported, as one naming nothing in the document itself is; a file that is not open is reported missing, with a likelier name offered where one is open. A schema’s $ref may also name one schema inside a file of schemas by name — $ref: schemas.yaml#/Pet, where schemas.yaml holds Pet: and Owner: and nothing else, or common.yaml#/components/schemas/Error in a file with no openapi:. In the diagram each schema of such a file is a card under its root, named by where it stands (referred into /Pet) — and so is a schema a $ref reaches inside a keyword a schema keeps as it is ($ref: "#/x-shared/Email"), under the schema that holds it. A path kept in a file of its own (/pets: {$ref: ./paths/pets.yaml}, the file holding get:, post: and the like) is part of the API: its operations stand in the Operations panel with the others, what they send and receive is listed under Starts at and can be checked by --operation, and you change those schemas in that file, where they are written.
The diagram starts at the interface: each path in a frame with its name above it, each operation a card of its own under it — GET, POST, PUT and DELETE apart, its summary when you hold the pointer over it, struck through when deprecated — and under each what it sends and receives, opened as any card is. Interface: every operation heads the start points; choose a message there to draw it alone. A WSDL is drawn the same way, by port type. Beside them stand the shared types — the types the messages are made of, in a frame of their own: one for each schema of a WSDL's types, named by its namespace, and one for every other interface. Each is closed at first and says how many types it holds; open it to see each type as a card. schemantix diagram draws the same overview, each path and each frame of types a subgraph in Mermaid and a frame in SVG.
A schema’s dialect. In 3.1 and 3.2 a schema of the document may say in $schema which dialect of JSON Schema it is written in, and the document may give every schema a default in jsonSchemaDialect. OpenAPI’s own dialect and JSON Schema 2020-12 are read; so is a dialect of 2020-12 whose meta-schema you open beside the document — its vocabularies then decide whether a schema’s value rules and format are checked, as for a JSON Schema. Another draft’s dialect, or a dialect whose meta-schema is not open, is reported as a warning, and the schema is checked in OpenAPI’s own dialect. A schema deeper inside may name a dialect of its own too, where it starts a resource of its own with an $id; everything inside it is then checked in that dialect. A $schema deeper inside without an $id is reported as a warning and not read.
A data document may start at any component as well as at a message: Starts at lists components/schemas too. On the command line a message may also be named by its operation: schemantix validate pet.json --schema api.yaml --operation 'GET /pets' --status 200 checks the 200 response (else the 2XX one, else the default one), and --request checks the request body; an operationId names the operation too, and generate takes the same. A Swagger 2.0 document (swagger: "2.0") is reported as one and not read: convert it to OpenAPI 3 first. After a change in the diagram, and when another document is opened, closed or changed, the document’s own findings — an operationId used twice, a $ref naming nothing — stay in Problems, at their places in the text.
To and from OpenAPI. A JSON Schema of any draft, or an XML Schema, becomes an OpenAPI document under Schema › Other version…: pick an OpenAPI version. Every schema becomes a component — each definition under its name, and the schema itself too, named after its title (Root where it has none) — and every $ref is rewritten to #/components/schemas/…. The document around them is the least one is: its version, an info with the title and version 1.0.0, and no paths, which are yours to write. In 3.0 a type list with null becomes nullable, a numeric exclusive bound a true beside its bound and examples one example; what 3.0 cannot hold — two types, two examples, a keyword it has not got, the schema’s own $id — is named in the status bar, never left out silently. The other way, an OpenAPI document becomes an XML Schema: each component a global element of its own named type, and every other schema of the API a named type. The XML Object is the XML both ways: a property with xml: {attribute: true} is an attribute, xml.name names the element, wrapped makes an element around the list, and a component’s xml.namespace is the target namespace — with a prefix, the elements inside are in no namespace, as OpenAPI writes them; without one, they are in it. An XML Schema becomes OpenAPI written so: its attributes with xml: {attribute: true}, its document elements with the target namespace. Both go through JSON Schema, and what either step cannot carry is named at the schema it belongs to.
The browser warns you before you leave the page while there are changes that were not downloaded.
Data documents
Next to schemas, a workspace holds data documents: JSON and XML files such as examples, test data or real messages. Each opens in its own tab (marked {} or ‹›) and is listed under Data files on the left. From JSON documents Schemantix can also propose a schema; see “Proposing a schema from data”.
SCML data schemas
An SCML data schema describes the data record an SCML template is filled with: named fields, the names of the required ones, and constraints across them. Its field types are text (with a pattern, min_length, max_length), bool, integer (min, max), the exact numbers decimal, money (with its currency) and measure (with its unit), date, datetime, enum (its values), a nested record, a list (of, min_items, max_items) and a tagged choice oneof (its variants). A schema of its own is a file named *.scml-schema.json. The schema of an SCML template is opened as one too, and a template is recognised by what it holds — a meta and a schema object — never by its name: a .template.json of Schemantix’s own (a schema template with its wizard) carries the mark "$schemantix" and stays what it is. There is one version, SCML 1; nothing in a data schema names one, so nothing is asked.
The diagram shows a record’s fields as properties, a list’s of as its items and a oneof as a choice of single-keyed records, the shape of the data ({ "incasso": { … } }). Add, rename and remove fields there, make them required, set their bounds, lengths, pattern and values. A money’s currency, a measure’s unit and a record’s constraints are kept as written and listed in the details; change them in the text. In a template only the schema is written again: everything around it — meta, body, bundle, signing — stays exactly as it was, character for character, and so does the order of the keys you wrote.
What is wrong with a schema is said where it stands, as the SCML engine would refuse it: a rule of the wrong JSON type ("min": "1" on an integer), a key a type needs and does not have (a money without currency), a decimal bound that is no exact decimal, a constraint naming a field its record does not have, a require-when value that is not of its field’s type, a pattern the engine does not read. A key a type does not read (min_lenght, a pattern on an integer) is a warning, since the engine passes it over. Numbers are exact: an integer is a JSON integer, and a decimal, money or measure is a string holding an exact decimal ("1500.00") or a whole JSON number — 1500.5 has already been through a float and is refused. A pattern is the Rust regex crate’s, matched against the whole value (\d{4}-\d{3} does not accept x2026-001); it has no look-around and no back-references, and runs in linear time, so no pattern is said to risk slow matching. The pattern help explains it as that crate reads it.
A data record — JSON, or YAML — beside the schema is judged as the SCML engine judges it before a fill: a required field missing, a value of the wrong type, not one of an enum’s values, not an exact decimal, a date not written YYYY-MM-DD, a text too short or too long or not matching its pattern, a number out of range, a list with too few or too many items, a choice that names no variant, a constraint that does not hold. A field the schema does not have is a warning. Each finding says, after its own sentence, the engine’s code and path for it (MissingRequired at regels[0].aantal). Example data — valid, broken by one constraint, or on and past every bound — is written as the engine reads it, exact numbers as strings, and keeps the record’s constraints.
Schema › Other version…, a JSON Schema version chosen there, writes the schema as JSON Schema 2020-12 as SCML’s own bridge does: an exact number as a string or whole number with a decimal pattern, a pattern anchored as ^(?:…)$, a oneof as a oneOf of single-keyed objects, and what JSON Schema has no word for — currency, unit, the exact bounds, the constraints — kept under x-scml and x-scml-constraints, so a schema written out and read back is the schema it was. A JSON Schema of another tool’s is read as an SCML data schema on a best-effort basis (a number becomes a decimal, an unanchored pattern is widened to match anywhere), and what it passes over is listed. File › New offers an SCML data schema. On the command line every command that reads a schema reads one: schemantix validate order.json --schema invoice.scml-schema.json, schemantix generate invoice.template.json, schemantix convert invoice.scml-schema.json --to json-schema, schemantix new scml.
YAML documents
A YAML document is data too: a file called .yaml or .yml, or one that opens as only YAML does — a --- line, a %YAML line, or a first line such as name: or - item with the rest reading as YAML. Pair it with a JSON Schema and it is checked exactly as a JSON document is, each finding underlined where the value stands in the YAML. It names its schema as a JSON document does, in a $schema at its top, or in the comment YAML editors read, # yaml-language-server: $schema=person.schema.json. Data › Write this document as JSON writes it as JSON beside it, and a JSON document is written as YAML the same way, keeping its schema; File › New › Data › Example for a schema writes the example as YAML where you choose Written as: YAML. The Data and Diagram views, editing a value in the grid, queries (JSONPath or XPath), the anonymised copy and proposing a schema all work as they do for JSON; a value you write in the grid stays a number where a number stood, and gets quotes only where YAML needs them. Suggestions while you type work as in JSON: Ctrl+Space offers the keys the schema allows at the indentation you are at, and the values of a key after its colon, inside {…} and […] written on one line too. Lay out is held back for YAML, since its indentation *is* its structure.
YAML is read as YAML 1.2: yes, no, on and off are words, not booleans, and .inf and .nan stay text because JSON has no such numbers. A key written twice is refused, and aliases may copy only so much, so a crafted file cannot make the editor build a billion nodes. A merge key (<<: *base) is YAML 1.1 and is an ordinary key unless you switch on Settings › Advanced settings › JSON and YAML › YAML data: read merge keys (<<); then a value the merge brings in is marked where the anchor writes it, and the grid still shows the file as written. A conversion reads merge keys all the same: written as JSON, XML, a table or a record file, <<: *base becomes the members it merges in, a member the mapping writes itself winning — what the author meant, rather than a key named <<. YAML conversions: read merge keys (<<) in the same place turns that off (--no-yaml-merge-keys on the command line), and the conversion then warns at every << that looks like a merge. The other way, a JSON document written as YAML that repeats the same members in several objects is told so, and Write the repeats once in the notice writes each run once under an anchor and merges it in elsewhere with <<: *shared1 — only where the YAML reads back as the same JSON (--yaml-share on the command line).
A file is recognised by what is in it
A data file does not have to be JSON or XML, and it does not have to be called anything in particular. A CSV, an R417 or BTX file, a fixed-position file from a mainframe: it opens as the text it is, whatever its name — prices.csv, batch.001 or no extension at all — because what it *is* is read from its content. A file you pick by hand always opens: you named it, so nothing second-guesses you. (A real binary is the one thing refused, by the one thing that tells one: a NUL character in it.) A text that looks like JSON or XML — its first character being {, [ or < — is read as that even when it does not parse, so a document you are halfway through writing still shows you its syntax error.
A record schema from the file itself
Any file can be opened, and is known for what it is. A plain file is paired with the schema in the workspace that reads it without an error — so you know it really fits. A record schema can also name its files, "files": ["*.R417"] (* any characters, ? one, upper or lower case alike), and a file of such a name is that schema’s at once, even one with errors, which is the file you want checked. A file of a kind nothing knows — an .R417, an .btx — that nothing recognised opens What is …?: its first lines as they were read, the schemas you may check it against (those that read it without an error say so), and, ticked, *Know files named *.R417 by this schema from now on*, which writes the name into the schema so the next such file is known. Or propose a record schema from it, or leave it as plain text.
A file that is neither JSON nor XML says nothing about its own shape, so nothing is checked about it until you say how to read it. Press Propose a record schema from this file beside the document: a record schema is read from the file, opens as a new unsaved document named after it, and the two are paired at once. From a CSV the header line names the columns and the values give the types; from a fixed-position file the field boundaries are where the characters line up down the lines, and the record types are told apart by the short code at the front of each line. A message of HL7 v2, EDIFACT or X12 is read by its first segment (MSH, UNA or UNB, ISA), which says its separators: a record type per kind of segment, a field per column, and fields of components where a column holds them.
Files of several record types are read as they are written. Cut by a separator, as an BTX file is cut by ~!, each record type gets as many fields as its own lines hold, and its code may run on into the first field (500PRINT~!). Written by position with the code further along the line, as an R417 file says its level at characters 31 to 34, the code is found where it stands — a code that comes back through the file, not a document number; where the lines of one record type go on to say what kind of line they are (RUBRKI, REGELR), each kind is a variant, and a last value written without the spaces after it is read all the same. Which record type stands under which is read from the order of the lines — a record type under the nearest one that always comes before it, but not under one it only follows after a list of them, and only where every line still stands where it would be read — and the status bar says what was put under what, to check. The way the file is written is recognised from its first 200 lines and its last; its codes, their nesting, how long each line may be and what its values are come from every line. A file that is not UTF-8 is proposed from in the page it was read in, and the schema names that page, so the file is read the same way when it is checked.
What it read, what it saw and what it guessed is said in the status bar, because a proposal is something you correct: ten lines of digits do not make a field a number, a column blank in every sample line is a boundary nobody meant, and a field blank somewhere is offered as optional — which a sample cannot tell from a field that happens to be absent here. Where nothing in the file says where one field ends and the next begins, you get no schema and a sentence saying why.
A record schema can also say which code page the file’s bytes stand for characters in — framing.encoding: EBCDIC (cp037, cp500, cp875, cp1026, cp273, and cp1140, cp1141 and cp1148, which are 37, 273 and 500 with the euro at 0x9F), a Latin page (iso-8859-1, iso-8859-15, windows-1252) or a Unicode one. EBCDIC is not even ASCII-compatible — 0xC1 is A there and 0x40 is a space — so nothing in the bytes states which page they are. A file you drop in is read by the page its bytes most look like, and where that is a guess rather than something the bytes settle, the status bar says which page was used and which others would also read the file. A byte-order mark or valid UTF-8 settles it and nothing is said, and so does an XML file’s own declaration: one saying encoding="ISO-8859-1" is read in Latin-1, as the command line reads it. Set framing.encoding when you know better than the guess, or when you are writing such a file: on the command line it is what schemantix validate <file> --schema <your record schema> reads the bytes with. Saving writes the file in its page again: the page it was read in, or — for a file made here, such as one written back from XML — the page its schema names. A character that page has no byte for (a euro in cp037) stops the save with a message saying which character and where, rather than writing a file that quietly holds the wrong one. A file read as UTF-16 is saved as UTF-16 again, its byte-order mark and all, and an XML file saved as UTF-8 says so in its declaration, where it named the encoding it was read in — otherwise no program would read it back.
A delimited file can be awkward in two ways, and both are read: the separator may be several characters — ~|~, ||, picked by files that chose a separator no field could hold instead of a quoting convention — and a quoted field may hold a line break, as an address or a typed-in note does, so a record carries on across lines. Write the separator yourself in the record schema’s framing; a proposal from a file of one kind of line only ever guesses a single character, because a sample cannot tell || apart from a |-separated file with an empty field in every record — from a file of several record types it also takes a pair of such characters that stands in every line, ~!. A line may leave its blank fields off its end: where the fields it stops before may be blank, they are read as blank. A file of positions is read the same way where a line stops inside or before fields of text padded with spaces, or inside a value standing at the left of its field, which is what an editor leaves of a line whose spaces at the end it has stripped; a line that stops before a number or a date is still too short. A last line of nothing but a DOS end-of-file mark (Ctrl-Z) is no record. A file that opens with a byte-order mark — what a spreadsheet writes for UTF-8 CSV — is read as though it did not. A record may end on a string of its own rather than on a line end — an EDIFACT segment on ', an X12 one on ~, an HL7 v2 one on a carriage return — written in the framing as "end": "'", or as a list where a file may be saved either way ("end": ["\r", "\n"]). The segments are then read alike whether the file has them all on one line or one to a line: the line ends after a segment are no part of the next one, the ruler shows a segment to a line, and a segment added in the grid ends as the file’s others do. A line end within a segment — an interchange wrapped at 80 characters — is layout too, as the standards have it; where a file’s values do hold line ends, say "lineEnds": "characters" in the framing. A field may hold fields of its own: components, and within a component subcomponents, each a field with a name and a type, listed in their order under the field’s components — HL7 v2’s Smith^John, EDIFACT’s UNOC:3; a component you have no need of is left out by giving the next one its number ("component": 3). A field that repeats on a character of its own (HL7 v2’s ~) says how often it may in occurs: a number, or "unbounded" for as often as the file has it — each record then holds as many repetitions as its column does, and each is placed, converted and written where it stands. A record type with such a field is read one way only: no variants, no stretch read several ways, no group a field counts. The separators stand in the framing (components, subcomponents, repetition), with the character that lets a value hold one: escape for HL7 v2’s \F\-like sequences, release for EDIFACT’s ?. Where a message names its own separators in its first segment, as HL7 v2’s MSH and EDIFACT’s UNA do, declared says which characters of that segment they are, and the file is read with them. A value written in the grid is written with its separators escaped, and a part the record does not have yet is added with the separators before it. A group need not be a line of the file at all: HL7 v2’s PATIENT or ORDER_OBSERVATION follows from the order of the segments in it. Declare it as a record type with "group": true, without codes or fields, and make it the parent of the record types within it: a group begins where its first segment stands, and begins again where a segment comes that the open one has already passed, or already holds as often as maxOccurs allows. Record types may then share a code where they stand within different ones — an NTE is a note to a patient, an order or an observation — and a segment is read as the type that fits where the file is at that point; the ruler indents each segment by the groups it stands in, and adding a group in the grid adds its first segment. A line may say what it is in other ways than by a code: "codePattern" — the codes 900 to 999 alike, "9[0-9]{2}", written as a field’s pattern is, a code written out winning over a pattern; "lineLength" — a line of exactly so many characters, which tells apart the kinds of line of a file with no code at all, or two types that share one; and "line": "first" or "line": "last" — a header or a trailer that carries no code. Where several types describe a line, the one that says the most of it is taken: the first or the last line before a code, a code before a pattern or a length. A line may say how deep it stands: "level": {"column": 1} beside the discriminator — GEDCOM’s 0 INDI, 1 NAME, 2 GIVN — and a record of level n stands within the open record of level n - 1, whatever came before it; "top": 1 where a file counts from one. Each record type has a field where the level stands, which a file written from data and a record added in the grid fill in. A message enclosed by a header and a trailer — EDIFACT’s UNH … UNT, X12’s ST … SE — is a group whose first and last members stand once: the next header begins another. A code may have two parts or more, at places of their own — a record code at the front and a kind letter at character 20: the discriminator is then a list of places, [{"position": 1, "length": 3}, {"position": 20, "length": 1}], and each code the list of its parts, ["100", "A"].
A file of fixed blocks — records of one length with no line end between them, as a mainframe writes them — is read with "framing": { "kind": "blocks", "length": 120 }: every 120 characters is a record, and fields stand at their positions as in a file of lines. In a single-byte code page such as EBCDIC a character is a byte, so the length is the record length the file was written with. A record type shorter than the block is padded out to it; a last block too short for its fields is reported. A file generated from such a schema is written the same way.
A file of records of varying length — a mainframe’s RECFM=V, sent with its record descriptor words kept — is read with "framing": { "kind": "rdw", "encoding": "cp037" }: four bytes before each record say how long it is, and fields stand at their positions within the record, the four bytes not counted. That is IBM’s way: the length in the first two bytes, most significant first, and counting the four bytes themselves. A file that went through other tools may differ, and the framing says how: "byteOrder": "little-endian" for the four bytes the other way round, "lengthCountsDescriptor": false for lengths that leave their own four bytes out — the record’s, and in blocks the block’s, as Cobrix reads them — and "blocked": true for records in blocks each opened by a block descriptor (RECFM=VB). Records spanned over segments (RECFM=VS, and VBS in blocks) are read with "spanned": true: each segment is opened by a descriptor whose third byte says whether it is a whole record, the first segment, a middle one or the last, and the segments are joined into one record — a field across two of them is read whole and shown from its first byte to its last in the file; a segment out of its place, or a file ending inside a record, stops the reading and is reported. With "segmentLength": 4000 a record longer than that is written in segments of at most 4000 bytes. A record may be shorter than its layout, as COBOL leaves off what a variable-length record does not hold: it is read as far as it goes, and a field past its end is not there. A descriptor that cannot be read stops the reading and is reported with what is wrong with it; a file generated or written back from such a schema gets its descriptors. Records of varying length laid back to back with no length in front — a transfer that dropped the descriptors — are read with "kind": "counted": each record is as long as its own counts say, its OCCURS … DEPENDING ON read first. A record type longer than its fields — bytes at its end no field describes — says so with its own "length": 4: each record of it is that long, what lies past its fields is skipped on reading and written as spaces, in this framing and every other. And where a record’s whole length stands in one of its own fields — Cobrix’s record_length_field — the record type names that field, "lengthField": "LEN", a whole number of its own outside any group: each record is as long as it says, shorter than its fields (a field it ends inside is read as far as it goes) or longer (the rest skipped). A length that is no number, or that ends before the field itself, stops the reading there; one past the end of the file is read as far as the file goes and reported. Written from data, the field holds the length the record is written at, and a warning says so where the document gave another; a field too narrow to say the longest its record can be — LEN PIC 9 over records of eleven bytes — is warned of on the schema. And a header or a trailer of a fixed size round the records, in any of these framings, is read past with "leadingBytes": 100 and "trailingBytes": 120; a file written from data gets as many spaces there.
A zoned number writes no minus sign: the sign is punched into one of its digits, which then stands as another character — { and A to I are a positive 0 to 9, } and J to R a negative one, so 000125} is −12.50 at a scale of two. Say so on the field with "sign": "trailing-overpunch" (the last digit, which is what a copybook’s PIC S9 means) or "leading-overpunch" (the first); a copybook import writes it for you. Such a field is written back the same way, nought-filled to its width. A copybook’s SIGN IS LEADING SEPARATE (or TRAILING) puts the sign in a character of its own, a + or a -, before or after the digits: that is "sign": "leading-separate" or "trailing-separate", and the field is one character wider than its digits.
A packed number (COBOL’s COMP-3) is not characters at all but bytes: two digits to a byte and the sign in the last half-byte, so S9(5)V99 COMP-3 is four bytes. Write it as "type": "packed" with a position, a length in bytes and, for a decimal, a scale; a copybook import writes it for you — and since such a file is mainframe data, frames it as cp037 in fixed blocks of the record’s length and says so, for you to change where your file is otherwise. Its bytes can only be read back through a code page of one byte to a character, so the framing must name one — cp037 or another EBCDIC page, or iso-8859-1 — and Problems says so if it does not. Such a field is written back packed, nought-filled to its width. A binary number (COMP, COMP-4, BINARY) is bytes in the same way: "type": "binary", one to eight bytes, negative in two’s complement, with a scale if it has an implied point — or "unsigned": true for a picture with no S, its first bit a digit, and "digits": 8 for the digits its picture has, which a value is held to as COBOL holds a PIC 9(8) COMP to eight (leave it out for a file written by a program compiled with TRUNC(BIN)); a copybook import makes it two, four or eight bytes by its digits — one byte for a COMP-9 of one or two digits, as Cobrix does — and leaves digits off a COMP-5 — COBOL’s native binary, which holds whatever its bytes hold (−32 768 to 32 767 in two bytes, 0 to 65 535 with no S), as Cobrix reads it — and a binary number with no digits is written back to a copybook as COMP-5 — and refuses one of more than 18 digits, which IBM COBOL does not allow, and COMP-0, which is Micro Focus’s and not IBM’s. A binary number written least significant byte first — Micro Focus COBOL’s COMP-5 on an Intel machine, Cobrix’s COMP-9 — says "byteOrder": "little-endian", where IBM’s way, the default, is "big-endian"; a copybook import writes it for every COMP-9, and for every COMP-5 where Settings › Advanced settings › Record files (or the command line’s --comp5) says the file came from such a machine. Binary-coded decimal — packed decimal without its sign half-byte, Cobrix’s COMP-3U and Micro Focus’s COMP-6 — is "type": "bcd": two digits to every byte and no sign, so three bytes hold six digits and no negative number, with a scale for an implied point; a copybook import reads both spellings and writes COMP-3U back. A floating-point number (COMP-1, COMP-2) is "type": "float", four bytes or eight: it is read as the shortest number that is written back as the same bytes, and written back byte for byte. Which format the file’s floats are in is said once, in the framing: "floats": "ibm" for IBM’s hexadecimal floats as z/OS writes them (the default), "ieee" for IEEE 754 as COBOL elsewhere writes them, either with -little-endian for its bytes the other way round — and a copybook import takes the one Settings › Advanced settings › Record files says. A number written for people to read — a copybook’s edited picture, PIC ZZ,ZZ9.99- — is "type": "edited" with that "picture", at a position and exactly as long as the picture is wide: read by taking the spaces, commas, signs and currency signs off, and written back with them, as COBOL writes it. A copybook’s scaling positions are read too: PIC 9(5)PPP holds five digits that stand for thousands — "scaling": 3 on a whole number, the noughts put back when it is read and taken off when it is written — and PIC PPP9(5) is a decimal whose five digits stand after three noughts, a scale of 8. National characters — a copybook’s PIC N, USAGE NATIONAL — are "type": "national": text in UTF-16, two bytes to a character, so PIC N(3) is six bytes at a position, padded with spaces, most significant byte first as IBM writes them unless the field says "byteOrder": "little-endian"; like every field held in bytes they need a code page of one byte to a character in the framing. A copybook import reads PIC N so, as Cobrix does, writes it back as PIC N, and refuses USAGE DISPLAY-1, IBM’s double-byte EBCDIC.
A trailer’s counts and totals are checked with assertions: tests in XPath on a record type, asked of every record of that type over the whole file. On a trailer, "assertions": [{ "test": "records = count(//order | //line)" }, { "test": "total = sum(//order/amount)" }] checks that its count and its total agree with the records before it. The record is the context, so a field of it is named as it stands (records), and the file is /, one element per record and one per field below it. Fields carry their kind — a decimal is a decimal — so a sum of amounts is exact to the cent. A test that is not true is reported on the record’s own line — in your own words if you write a "message" beside the "test"; a test that is no XPath is reported on the schema and judges nothing. "assertions" at the top of the schema are about the file as a whole, asked once of the document. A schema with assertions reads its file twice, the second time whole. Example data fills in what an assertion gives a field: a test that says one field of its record is something — records = count(//order) + 1, total = sum(//order/amount), either way round — gets that value, counted and added up over the records the generator made, so a trailer agrees with the file it closes. Any other test is checked and not filled in: where such tests are all that is wrong, the generator says so at the record type, and you set those values by hand. While you write a test, the editor completes it as the Query tab completes a query — the record types and fields of this schema, and the functions of XPath (Ctrl+Space) — and a test that does not read is marked at the very character where it stops, with the standard’s code in the finding. The usual ones need no XPath: a closing record’s controls say what each of its fields controls — { "field": "records", "counts": "records" } (or "between" for the records between the first and the last, or a record type, with "from" a record type to count from as EDIFACT’s UNT does), "sums": "order/amount" for a control total, "hashes" for a hash total, "equals": "header/batch" for the header’s value. In the ruler, pick the field and choose under This field controls. A control that does not agree is said with both sides — what the field says and what the file comes to — and a file written from the schema has them filled in. A proposal from a sample offers them where a number of its last record comes to a count or a sum of the file.
A record type read two ways — a payment by card or by bank, the same characters holding a card number or an account — has variants: "variantBy": "method" names the field that chooses, and "variants": [{ "name": "card", "codes": ["C"], "fields": [ … ] }, { "name": "bank", "codes": ["B"], "fields": [ … ] }] says what each value of it means. In the diagram each variant is a card of its own, called by its name with the codes that choose it beside it (when B or G). A record has its type’s own fields and then its variant’s, which may stand over the same characters as another variant’s. It is what a COBOL REDEFINES describes, and a copybook import makes the variants for you — the item redefined and each item that redefines it — but a copybook does not say which field chooses, so you add variantBy and each variant’s codes yourself; Problems asks for them until you do. A value no variant claims is read as the type’s own fields alone, and the choosing field’s own codes say whether it is allowed. A record has one set of variants — the readings of one of its own items — and every other REDEFINES in it, deeper in a group or a second one, is a choice of its own (see the next tip); if you would rather not choose at all, turn on Settings › Advanced settings › Record files › Copybooks: keep the first reading of a REDEFINES before opening the copybook. Then the first reading counts and every later one becomes a field with "redefines": read over the same characters where it fits, empty where it does not, never reported as wrong and never written back — any number of them, inside a repeating group too. schemantix propose-record --copybook --redefines first-reading does the same. A variant may hold a group whose count varies — an OCCURS … DEPENDING ON inside a REDEFINES, common in older bank and insurance files: only the variant’s own fields after the group move up by what it does not hold, and the record type’s own fields after the variant keep their place, as Cobrix reads them — with the first reading counting too, where only the first reading’s count is read. Every record of a type with variants is as long as its longest variant, whichever variant it is: written padded with spaces to that length, as Cobrix advances past a REDEFINES by its declared size, and a line that ends early among a variant’s characters is read as if the spaces were there — an editor strips them from the end of a line — rather than reported as too short.
A record may hold several stretches each read its own way — the payment method and the address form, say — and each is a choice: a field with "variantBy" and "variants", { "name": "detail", "position": 2, "length": 4, "variantBy": "method", "variants": [{ "name": "card", "codes": ["C"], "fields": [ … ] }, { "name": "bank", "codes": ["B"], "fields": [ … ] }] }. Each variant is a reading of the stretch, its fields placed from position 1 of it; the reading whose codes hold what the variantBy field holds is read, and the others are no fields of the record — no value, nothing reported, nothing written. The choosing field stands before the stretch. In the data only the chosen reading appears, where the stretch stands, with no extra layer. A copybook import makes every REDEFINES other than the record’s own variants a choice; it cannot say which field chooses, so until you add variantBy and the codes, every reading is read and the first counts — Problems reminds you with a warning. A reading may hold a group whose count varies (OCCURS … DEPENDING ON inside a REDEFINES): the reading’s fields after it move up by what it does not hold, but the stretch keeps the length it is declared with, so what follows it stays where it is declared. Every stretch is as long as it is declared, whichever reading it holds: a record that ends in it is written padded with spaces to its end, and a line that ends early in it is read as if the spaces were there — an editor strips them — rather than reported as too short. A group in a reading not chosen is not counted at all; until a field chooses, only the first reading’s is. On the ruler, each line says beside its record type which reading of each stretch it is (the stretch’s name in the tooltip), and that reading’s fields have grips and stops there, moved within the stretch as a variant’s fields are on a line of that variant.
A record schema can be written back as a COBOL copybook: Schema › COBOL copybook (.cpy) downloads it, and schemantix convert orders.record.json --to copybook writes it on the command line. Each record type becomes an 01 level, each field an entry with its PIC and USAGE, a gap a FILLER, a group a group item, a repeating group an OCCURS, and a choice its first reading followed by each other one as a REDEFINES. A record type longer than its fields (its own length) ends in a FILLER; the other way round, a FILLER at the end of a copybook’s record is read as that length, so a line holding it is not called too long. What a copybook cannot say — which characters say what record a line is, which record type stands under which, which field chooses a reading, a date’s picture — is written as a comment and listed in the notice. A copybook you open, correct in the ruler and write back comes out as the same structure, with your corrections in it. A CSV has no copybook.
A record schema written as XSD (Schema › Other version (download or convert)…, or schemantix convert orders.record.json --to xsd) keeps the shape of its file and its layout: the file one element, root, its record types in their order and nesting, each field an element, and where each stands, its width, its padding and the rest as attributes — DFDL’s names where DFDL says the same, Schemantix’s own for the rest. Converted back, it is the record schema it was. An XSD with DFDL’s annotations — a DFDL schema someone else wrote — converted to a record schema is read through its layout: where each field stands, how wide it is, how it is padded, packed or signed. What a record schema says only approximately, and a layout it cannot say yet, is said in the notes.
A group of fields that repeats — three order lines in every invoice record, COBOL’s OCCURS — is a field with "occurs" and fields of its own: { "name": "lines", "occurs": 3, "position": 5, "length": 7, "fields": [ { "name": "article", "position": 1, "length": 5 }, { "name": "quantity", "type": "integer", "position": 6, "length": 2 } ] }. The group’s fields are placed within one occurrence, from position 1 of it; the occurrences follow one another from the group’s position, each length characters. Problems places a fault in its occurrence (/invoice[1]/lines[2]/quantity), the file converts to an element per occurrence (a list in JSON), and a copybook’s OCCURS 3 TIMES is imported as such a group. A count that varies — COBOL’s OCCURS … DEPENDING ON, the variable-length record — is said with "dependingOn": "parcels", naming a whole-number field before the group: occurs is then the most there may be, each line is as long as its count says, and whatever follows the group stands that much nearer the front. A group may stand within a group — COBOL’s table of tables, an OCCURS within an OCCURS, up to seven deep: write it among the outer group’s fields with its own occurs, its position counted within one occurrence of the outer group. Its count may vary too, by a field of its own occurrence or of one around it — IBM’s “complex OCCURS DEPENDING ON”. A field whose length another field holds — a DB2 VARCHAR unloaded without padding, DFDL’s dfdl:length="{ ../len }" — says "dependingOn": "len" on the field itself: its length is then the most it may be, each record has it as many characters long as len holds, and whatever follows it stands that much nearer the front, as after a group whose count varies. A packed, binary-coded or binary number may say it too, its length then in bytes, and written from data it is as many bytes long as its value needs; so may a group with no occurs — its length the most it may be, a field it ends before not there and one it ends inside read as far as it goes; and the field may be named by its path from the record type, "dependingOn": "/order/header/len", where a name alone is not enough. A length in bits is not said: a record schema counts characters and bytes. A length past the most is said of the field, which is read at its most. Written from data, a length that says more than the value is kept and the value padded to it; one that says less, or none, becomes the value’s own width — and a warning says so, naming the field, the length given and the length written. It is text, a code or a number written in digits, at a position; a copybook has no spelling for it, so a copybook written from the schema has the field at its most and says what it left out.
A group that does not repeat — COBOL’s 05 ADDRESS with its 10 fields — is a field with fields of its own and no "occurs": { "name": "address", "position": 3, "length": 9, "fields": [ { "name": "street", "position": 1, "length": 4 }, { "name": "city", "position": 5, "length": 5 } ] }. Its fields are placed within it, from position 1 of it, and in the data it is an object (JSON, YAML) or an element (XML) holding them: "address": { "street": …, "city": … }. A copybook import keeps every named group so, nested as COBOL and Cobrix nest them. Groups stand within groups up to 47 deep, of which seven may repeat. A count field inside a group may count a table after it, as DEPENDING ON may name any field before the table.
Written as JSON or YAML, a record file follows its schema: a record type or a group that may repeat is a list even where the file holds one of it, so whatever reads the result finds a list every time. A file in which the schema recognised nothing — not one line it could read — is not converted at all, since an empty document would say the file holds nothing; it nearly always means the wrong schema. And a field that covers part of the discriminator’s characters is a warning in Problems: every line written would have the record type’s code over part of its value. A field exactly on the discriminator is fine — it is the code itself.
Writing a record schema by hand
You need not start from a proposal: a record schema is ordinary JSON, so you can type one yourself. Where a key is wrong or missing, Problems says what belongs there — and where it is short enough to write out, the example comes with it: “Write for example: "column": 1”. One almost everybody meets: a field with "type": "boolean" has to say for itself how that truth is written in the file, because there is no convention — it is as often Y/N or 1/0 as true/false. So write "true": "true", "false": "false", or whatever your own file writes.
You can also make an empty data document to paste into: File › New… › Data and then Plain text instead of JSON or XML. That is what a record file is — neither JSON nor XML — and nothing is said about it until you pair it with a schema. Choose a record schema there instead, and you get a record file straight away rather than a JSON document.
Correcting a schema against your own file (the Ruler)
A proposal is a reading of your file and not a description of your format, and the one thing it can never find is an implied point: 000001250 is nine digits, and only you know whether that is 1 250 or 12.50. So show the record schema and open the Ruler below the editor. It draws the first lines of a sample paired with that schema: a column scale, the record type that claimed each line, every field across the characters it covers, and — when you hover one — what those characters read as. Nine digits reading as 1250 is the fault; the same nine digits reading as 12.50 is the fix.
Characters no field names are drawn with a dashed line. A click on them makes them a field, up to the next field; a column of plain whole numbers is read as one, anything else as text, and you can change that in the form beside the lines.
Click a field and its form opens on the right, beside the lines, which scroll sideways on their own: give it a name that says what it holds (a proposal calls its fields field1, field2 — renaming one renames what refers to it, as in the diagram; a name the schema cannot take, such as one with a space in it, is said under the field as you type and not taken, so you correct it right there; a name that is already wrong, typed in the text, can be corrected in this field even while the rest of the field is locked, or with the rename Problems offers), and say what its characters mean (text, a whole number, a number, a date, a time, true-or-false, one of a list of codes) and set everything about where it stands: the position and the length — which is how you move a boundary — the padding character, the alignment, and the digits after the implied point. Your file is read again at once, so the value under each field is always what the schema now says, and the findings about the file stand in Problems beside the ruler. Nothing you do here touches the file itself: a ruler corrects the schema.
Or pull a boundary with the mouse. Take hold of either edge of a field and drag it over the characters: while you hold it the field is drawn where it would stand, and beneath the lines you can read the position and the length it would get. Pulling the end moves the last character and leaves the first where it is; pulling the start does the opposite. Let go and your file is read again. A drag that would cover the next field is refused while you hold it — it says which field — and so is one let go of outside the lines; nothing is written in either case, and Escape lets go without writing. It is the same edit as typing the two numbers, so one Undo puts the boundary back. A field of a delimited file stands at a *column* and has no edge to pull: there, where the characters fall depends on every quoted comma before it.
Or lay the fields out with stops, as tab stops in a word processor. The scale above the lines has a ▼ wherever a field of the record type begins or ends (the record type of the field you picked, or of the first line), and a line runs down from each through the sample, so you see which character stands under it; while you drag a ▼ or a field’s edge, the line goes with the pointer, drawn stronger. The sample is shown in a font of one width, so every character takes one column. Click the scale inside a field to split it there — the field keeps the first part and a new field takes the rest, right after it — or over characters no field covers to start a field there. Drag a ▼ to move the boundary: both fields it touches follow. Double-click a ▼, or drag it off the scale, to take it away and join the two fields either side of it. Where a ▼ has empty characters on one side, the field on its other side takes them in, up to the next field or the end of the line. Each is one step to undo, and the schema’s text follows it as it follows any edit. A field split this way is called field and a number until you name it. The fields of a group — a copybook’s 05 ADDRESS with its 10 fields — have stops too, within their group: a split or a new field stays in the group, and a ▼ inside it moves no further than the group’s edges, which stay where they are. A repeating group’s fields, and a choice’s readings, are drawn but not moved.
A file of nested records — a header 100, orders 200 and, within each order, its lines 300 — is shown by its structure: one example of each record type in its place, taken where the most kinds of record stand under it, each line indented by how deep it stands. Between two lines shown, ⋯ says the file goes on there. Click a record type at the front of its line and the scale at the top becomes that record type’s, indented with the line so its ▼s stand over its characters. Each record type keeps the field you picked on it and how far you scrolled sideways, so going from a 300 to a 200 and back finds the 300 as you left it — next time you open the schema too. A record standing where the nesting does not allow it — a 300 with no 200 above it — is marked in red, and Problems says why. First lines, in the Ruler’s heading, shows the first lines of the file instead; Structure brings the structure back. A file of one record type is shown by its first lines.
Say what a line is, and where it stands. Click The code of a line in the Ruler’s heading and drag along the characters of a line that say what it is — the 100 at its front. Then choose the record type they are the code of, or a new record type… with a name, and Make it so. The first time, this also says where every line’s code stands, and every record type’s codes are read again from its own lines there, so a file read as one kind of line becomes one of several without losing a line. Hold Ctrl and drag again for a second part of the code — a kind letter at character 20. Or choose say how deep every line stands for characters that hold a level, as GEDCOM’s 0, 1, 2: every record type then stands where the levels put its lines.
Put a line under another, as in an outline. Click a line at its front and press Tab: its record type now stands under the line before it — a 300 under its 200. Shift+Tab takes it out again; dragging the front to the right or the left does the same. Shift+click the front of a second line to take the lines between together: Make them a group puts their record types in a group that no line is, which their order opens and closes (HL7 v2’s PATIENT), and They enclose a group makes the first line open a group and the last close it (EDIFACT’s UNH … UNT). Propose the structure does it all at once from the order of the lines, how often each record type occurs included. Beside the lines, the form of the record type says the same in words — Stands under, Occurs, and how a line is known to be one: its codes, A code like (a pattern such as 9[0-9]{2}), Its length, Its place (the first or the last line). Every change is one step to undo.
A record type with variants — a payment by card or by bank, chosen by its method field — is shown per line: beside each line stands the variant that line is (hover it for its record type too), and the line shows that variant’s fields. The scale is of the line you picked a field on, so click a field on a bank line and the ▼s are the bank layout’s. A variant’s fields are split, started, moved and joined there like any other field, and their edges are pulled the same way; a field started over empty characters on a variant’s line belongs to that variant. Two variants may stand over the same characters — that is what variants are — so a card field pulled across what a bank line calls its account is not refused; a field of the record type itself stands on every line, and is still kept off every variant’s characters.
A delimited file — a CSV — has stops of its own. Its fields stand at columns, and what stands between two of them is the file’s delimiter, one for the whole file. So each line shows where it is divided, with a line down from every divider, and the scale numbers the columns of one line (the line you picked a field on, or the first that is not the header; the header line says header beside it). Two buttons in the Ruler’s heading act on the whole file. A delimited file has no edges to drag — its fields are found by counting delimiters — and the panel beside the lines says so until you pick a field. Split on a character: click a character in any line — a ; in a file read with ,, say — or drag along several for a delimiter such as ||, or type them in the box that appears. Read by positions, or double-click a divider on the scale: the cutting is taken away. Either way the Ruler first says what it would do — “article: 1 column becomes 4.”, the fields it adds, the lines no record type claims any more — and only Split (or Read by positions) makes it; Cancel leaves the file as it is. A split makes those characters the delimiter: your fields keep their names, kinds and columns, and each column past the last one gets a field named from the header line (or column3, …) with its kind read from the values; a field past every column its lines now have is kept, and said. Read by positions, each field takes its column’s place where the columns stand at the same characters on every line, and where they do not, one field covers the line and you set the stops yourself. Either is one step to undo, and both change the schema’s framing, so they are not offered while the diagram is locked. Joining two columns into one field is not offered: the file still holds the delimiter between them. On the command line, schemantix edit prices.record.json --sample prices.csv --split-on ";" (or --read-by-positions) does the same and says what it did.
A line nothing has claimed yet is still drawn, with its record type said to be missing — because a file that does not fit its schema is exactly what you are looking at while you correct one. And the ruler is read-only wherever the diagram is: if the schema’s text has errors, fix those first (see “When the diagram is locked”) — except a field’s Name when the name itself is what is wrong: that you correct right there.
An anonymised copy to share. A sample may hold production data you cannot send on. Anonymised copy, in the Ruler’s heading — or Data › Anonymised copy of this document for any data document, XML and JSON as much as a record file — makes a copy of the sample with every value replaced by a generated one of the same kind and width, and opens it beside the sample, which stays as it is. What says what a record is stays: the record type’s code, the field that chooses a variant, the count of a repeating part — and so does a field that holds nothing. A value met twice in fields of the same kind and width gets the same replacement both times, so an order number in the order and in its lines still matches. Characters no field describes — a filler, a gap between fields, a column no field names, the end of a line longer than its layout — are replaced too, letter by letter and digit by digit, with spaces and punctuation kept where they are; a line no record type claims keeps its record type’s code and has its letters and digits scrambled. A letter such as é, ü or a Greek letter is replaced by another letter of the same case that the file’s code page has. What is written only in punctuation or symbols is kept, so describe such a stretch as a field if it may hold data. The copy is checked against your schema like any document, so the Problems panel shows anything the new values break — a control total in a trailer, say. A message says how many values were replaced and what was kept. An XML or JSON document is done value by value: where a schema is attached, each value is replaced by one its schema allows (so the copy stays valid against it), and where none is, by one of the same shape — a number by a number with as many digits, a date by a valid date, true or false by one of the two; element and attribute names, keys and namespaces stay, and comments are scrambled. Kept to your own rules: a masking file beside the schema — JSON opening with "$schemantix": "masking/1" — says per field (by its place in the schema, #/properties/iban) or per kind of value (email, iban, date, dateTime, found by its shape) what is done: keep it, characters (****1234, with with, keepFirst, keepLast), name (an invented name, locale en or nl), email (the domain kept), iban (the country kept, the check digits computed again), shiftDays (moved by days), scrambled (each letter and digit another of its sort), or generated (as above). A rule may also stand at a field’s name wherever it stands ("fields": {"PID.5.1.1": …}), and "otherwise" says what is done with every value no rule names; a name rule may give one part, family or given. A field’s rule wins over its name’s, and that over its kind’s, and a copy masks the same value the same way wherever it stands, so a value met twice is masked the same. Data › Anonymised copy, kept to … offers each masking file of the workspace; on the command line, schemantix anonymise data.json --rules data.masking.json, a record file of any size included.
A change that stays valid (1.154.0). To find out whether a chain of integrations notices a fault that no schema check catches, Data › Make a valid change… makes one change in the document shown that leaves it valid against its schema: an amount a cent off, a number one up or down, a date a day out, a text cut short, an optional part left out, another code of its list, two dates swapped, an item repeated, two items reordered, or a text read in the wrong encoding (é becomes é). It is made only where the schema says the change fits, and kept only where the document then still passes every rule of its schema — a record file’s too, written in the file’s own layout. The dialog says where the change was made, what stood there and what stands there now; Another place tries the next one, and Open as a document opens the changed document beside the original, which stays as it is. Where no place takes the change, it says so. On the command line, schemantix change order.json --schema order.schema.json --kind amountOffByOneCent, with --at to name the place in the schema and --kind staleVersion for an earlier value there.
A record file as XML, JSON or YAML, and back. With a record file shown and its schema attached, Data › Write this document as XML (or JSON, or YAML) writes the file as the schema reads it — one element or object per record, one per field, the same tree a stylesheet sees — and opens it beside the file, which stays as it is. The XML is wrapped in one element, root unless Settings › Advanced settings › Record files names another. No stylesheet is needed. The other way round, with an XML, JSON or YAML document shown, Data › Write as a file of … offers each record schema of the workspace and writes the document back as a record file of that schema, paired with it. A document that does not match the schema is not written: the message says where it does not, as the Problems panel would. The command line does the same with schemantix convert <file> --schema <record schema> --to xml (or --to record).
An XML document as JSON or YAML, and back. With an XML document shown, Data › Write this document as JSON (or YAML) writes it beside it with no schema: the root element is the outer key, an attribute is @ and its name ("@id": "7"), a namespace it declares is @xmlns:p, text beside child elements is #text, a name that occurs twice is a list, and every value is text, since nothing says what is a number. Data › Write this document as XML goes the other way, and gives the same XML back. A JSON document that is not one member at its top — the root element — or that names something XML cannot, is refused, and the message says where. On the command line: schemantix convert order.xml --to json.
Any document as a table, and a table as any document. Data › Write this document as CSV flattens a JSON, YAML or XML document: a column per path (line.sku), a row per item of a list with what stands beside it repeated, and a header row. A CSV with no schema is offered as XML, JSON and YAML too: it is read through the record schema its header and rows propose, as File › New… › Schema › Proposed from sample data would make it. On the command line: schemantix convert order.json --to csv, schemantix convert people.csv --to json.
Flattened into a record file. A JSON, YAML or XML document whose shape is not the record schema’s can still be written as its file: Data › Write flattened as a file of … makes it a table first, as CSV, and writes each row as one record. A column goes to the field of its name, compared without case and without anything but letters and digits (customer.name is CUSTOMER-NAME), by its whole path or by the end of it (billing.city is city) where only one column ends that way. A column no field takes is not written, and the notice says which. A required field no column fills is refused, as when writing a document of the schema’s own shape. Into a schema of more than one record type each row is a record of the type whose fields its columns fill most (the first of two that tie), and what the schema then asks — a header, a record only within another — is judged as for a document of its own shape; a row that fills no field of any type is refused. A field of a group that repeats is filled in its first occurrence. On the command line: schemantix convert order.json --schema batch.record.json --to record --flatten. A record file is offered the same way, as a file of any *other* record schema in the workspace: it is read through its own schema — or, a CSV with none, through the one its rows propose — so a copybook’s file becomes a CSV, or a CSV a file of fixed positions, in one step; a header’s fields are repeated on every row. On the command line, --from names the schema the file is read through: schemantix convert batch.dat --from batch.record.json --schema lines.record.json --to record --flatten. And a record file paired with its schema is offered Write this document as CSV too: a plain table with no schema made for it, a row per record of the deepest kind with the fields of the records around it (a header, an order) repeated on each — schemantix convert batch.dat --schema batch.record.json --to csv.
Through its XSD, typed. An XML document paired with its XSD is written as JSON or YAML through it: a value the schema says is a number is a number, written as the document wrote it (12.50), a boolean is true or false, and an element the schema lets repeat is a list even where the document holds one. What does not match the schema stays text. On the command line: schemantix convert order.xml --schema order.xsd --to json.
Through its JSON Schema. A JSON or YAML document paired with its JSON Schema is written as XML through it: each member an element, each item of a list an element of the member’s name, the whole in one element — root unless Settings › Advanced settings › Record files names another. That XML, paired with the same schema, is written back as the JSON the schema describes: its outer element taken off, a number a number and a field that may repeat a list. A document whose schema reads no JSON is written as with no schema. On the command line: schemantix convert order.json --schema order.schema.json --to xml --root order.
A schema of your own from a generic one. Where one large generic schema stands behind one API, a template (.template.json) says what may be chosen on it: parts to switch off, fields to make required, the values allowed, a fixed value. Open the generic schema and the template, show the template, and choose Schema › Run this template…. The wizard asks each choice — a part inside a block you switch off is not asked — and Name says what the result is called. Generate opens the derived schema beside the rest and keeps your choices in an answers file (<name>.answers.json); where the run has remarks, the wizard stays open and lists them under “Written …, with these remarks:”, and Close shuts it; show that file and choose Schema › Run these answers again… to change them, or to write the schema anew after the generic one changed. A derived schema only ever narrows the generic one, so every document valid against it is valid against the generic one too: a choice that would widen it is refused, and the wizard says why, at the choice it is about, and writes nothing. A slot is a place the generic schema leaves open for each document type’s own data: give it a schema of the workspace, or New schema for this… to build one, or propose one from a sample of the data to correct — those two keep your answers and close the wizard, so you build or correct the schema and then run the answers again. The derived schema is one file, the slot’s schema folded into it — except in XSD where the slot is a wildcard of another namespace (##other) and the slot’s schema is in that namespace: then it is imported and stays a file of its own beside the derived schema, and the wizard warns that a document may now also begin at its root element. The command line does the same with schemantix derive <answers>.
A field of the value’s type. Where the generic schema lists no values, the wizard asks a value in a field of its type, read from the schema: a truth as Yes (true) or No (false) to choose, or two ticks where the values allowed are chosen; a number in a number field held to its bounds; a date, a time or a moment in the browser’s own picker; a text with its length, and an e-mail address or a web address as such. A choice of values is made one value at a time: type it, Add, and take one off again with ×. Beside each field stands what it allows — 1–99, at most 35 characters — and a value is checked as it is typed, by the same rule Generate applies: below or above a bound, not a multiple of a step, too many decimals, too short or too long, not matching the schema’s pattern (read as the schema’s own kind of pattern, XSD’s for an XSD). Why is said under the field, and Generate stays off until it is put right. A number is written to the answers exactly as typed; one with more digits than can be kept exactly is said rather than rounded. Where the schema says nothing a field can be shown for, the value is typed as before.
Making a template. Show the generic schema and choose Schema › Template for this schema… (or File › New… › Schema template (wizard) for a schema you choose). The diagram becomes the template’s: a bar over it says so, with Try in the wizard and Done; every card that is a choice carries a badge; and the Template panel stands where the node details do. Select a card and the panel offers it as each kind of choice that works there — a block to switch off and a choice of required or not for an optional part, a choice of values and a fixed value for a field that holds a value, an open slot for a place left open; right-clicking the card offers the same. Only while you design: editing the schema itself offers no template choices. In the panel each choice has its label and help, in your own words, buttons to move it up or down or remove it, and what its kind can say: on or off by default, the values offered, the ways a slot may be filled. The schema itself is not changed while you design: its text comes back with Done. The template is kept as a .template.json file beside the schema, which you never need to open. A card inside a reference — an address that refers to a definition Address, perhaps in another document — is offered for that place alone: the billing address can be restricted to NL while the delivery address stays any Address. A place that offers a choice — a oneOf, an anyOf, an XSD choice — can be offered as a choice between alternatives: tick in the panel which alternatives the wizard shows, and in the wizard one of them is chosen, or several; the derived schema keeps those. Where the choice is “at least one of these properties” — {"required": ["print"]} and so on — a property not chosen goes from the derived schema too — also where the choice stands behind a reference, and where an alternative says more than which property it requires. One chosen alone is simply required where its alternative says nothing else; one that says more stays an anyOf of one, so none of its rules is lost. Where properties not chosen have to stay — they are declared in an allOf or behind a reference rather than beside the choice, or an alternative requires no property by name — the wizard says so in a warning. Under each choice, Asked only when makes it wait for another: the SMS sender asked only where the channel is SMS. And Fixed — not asked makes the choice the template’s own: what is set there is applied, and the wizard does not ask it — the channel made required, the choices of channel still asked beside it, since a card may be offered as several kinds as long as one of them alone is asked. A part that repeats can be offered as how often it may stand, and a number or a text as bounds and lengths: a least and a most (and in XSD the digits after the point), never beyond what the schema allows, each field saying what that is. A value of several types can be offered as a choice of types, an object open to other properties as closed to other properties, and an XSD element others may stand in for as a choice of substitutes — those not chosen leave the schema, so the choice holds wherever that element stands.
When the generic schema changes. The wizard checks the template as it opens: a choice whose place the generic schema no longer has, or a value it no longer allows, is said at once, and Generate stays off until the template is corrected. To write every derived schema anew, choose Schema › Run every answers file again: each answers file of the workspace is run as Generate would, and the message names any that could not be written. The command line does the same with schemantix derive --all <folder>.
A template in several languages. A template may give its title and each choice’s label and help in several languages. In the template panel, fill in The template’s own language (a tag such as en or nl) and Other languages, and each text then has a field per language, the template’s own first. The wizard shows the text of the language you use Schemantix in, else the template’s own. The panel says a text given in a language the template does not declare, and one given per language but not in the template’s own; so does schemantix derive, and neither stops anything. Values are not translated: they are data.
Checked as it opens, typed as it is offered. Run an answers file again and the wizard judges every answer in it as Generate would: a value beyond its bounds, of the wrong type, or one the template no longer offers is said under its choice until you answer that choice anew, and Generate stays off meanwhile; an answer to no choice of the template is listed above the choices. In the template panel, the values a choice offers are typed in the same fields the wizard has — two ticks for a truth, a number held to its bounds, a date picked — and checked as they are typed. A pattern on a number or a truth, such as an XSD xs:pattern on an xs:integer, is checked too, against the value as the derived schema writes it (012 typed is the number 12); JSON Schema’s pattern asks only texts, so there it is not.
The same controls are in the inspector, under Place in the text, for a field you have selected in the diagram — the same words for what the characters mean and the same list for an alignment, with or without a sample open.
Asking a record file a question
Show the file and the Query tab asks XPath 3.1 about the tree your schema makes of it: count(//order), //order[2]/number, sum(//order/amount ! xs:decimal(.)). That is how you check a proposed schema — if the numbers come out wrong, the schema is wrong. The file must be paired with a schema (without one there is no tree to ask about), a result says where it stands in the tree rather than in the text, and the values are text: add ! xs:decimal(.) where you want exact arithmetic. JSONPath is not offered for such a file, being a language about JSON.
Opening and making them
- Opening files — with File › Open…, Open folder…, a zip or by dropping them — tells schemas from data by itself:
.xsdand.schema.jsonfiles, and files that look like a schema (anxs:schemaelement, a$schemanaming a JSON Schema version such ashttps://json-schema.org/draft/2020-12/schema, or only schema keywords), open as schemas; other JSON and XML files open as data. - File › New… › Data (or + in the tab bar) makes a new one. Example for a schema starts as a minimal valid example of it — only what the schema requires; otherwise it starts empty, as XML, JSON, YAML or plain text. CSV and Fixed width make the file and a record schema for it together, so the delimiter you choose is the one it is read by.
- In the generator profile, Open in tabs opens generated examples as data documents instead of downloading them.
Its schema
Above the text, Schema shows the schema the document is checked against. It is found by itself when the document names it — xsi:schemaLocation or xsi:noNamespaceSchemaLocation in XML, $schema in JSON — or when the workspace has only one schema of its kind. Choose another schema, or none, at any time; only schemas that can check the document are offered (JSON Schemas and OpenAPI documents for JSON and YAML, XSDs for XML, record schemas for plain text). If the document is attached to one that cannot — named in the document, or no longer readable — the status bar says it is not checked against it. Starts at appears beside it where a JSON Schema has more than one place a document can begin — its root and each of its $defs, or in an OpenAPI document each message and each component — and says which one this document is: a document holding one address is checked against #/$defs/address, not against the whole schema. Left at “chosen from the document”, it starts at the root. An XML document is offered its schema’s global elements: left at “chosen from the document”, its own element chooses the declaration; choose one, and it is checked against that declaration whatever its element is called — useful for a fragment cut from a larger document.
Seeing it as a tree and a table
A data document has three views below it, in the same order and under the same names as a schema’s: Text, Diagram and Grid. Grid shows what the document holds as a tree: every value can be edited where it stands, and what is repeated becomes a table — one row per item, one column per name — which is how most people would rather write a hundred records. What an item holds besides its values — a group, or a list of its own — stands under its row and opens there. What you change in the Grid and Diagram views is undone and redone with the arrows in the toolbar; in the Text view the editor keeps its own history (Ctrl+Z), and typing there starts the other one afresh. In JSON a list is an array; in XML it is the elements of one name under one parent. A list of bare values stays a tree, because a table without columns says nothing. Diagram draws the same document as cards, read from left to right the way a schema is, with every value edited on its own card and +N to open what a card holds — or Expand all and Collapse all above the canvas, as for a schema. A document you open is put in the middle of the canvas, like a schema: one larger than the window is zoomed out until it fits, a smaller one keeps its own size. Which of the three you had a document on is remembered for that document, so it comes back that way — the next time you open Schemantix too. A document that is neither XML nor JSON (the result of a transformation written as HTML or as text) has no structure to show, so it has only its text — unless its schema reads it, as a record file’s does (below).
A large document opens a part at a time. The grid draws a long list a couple of hundred rows at a time, the next as you scroll to them, and the diagram draws only the cards in view. What a document holds comes to the views in parts as well: of a list deep in a large file the first items come along, and the rest as you open it or scroll to them — on a diagram card, Show more brings the next of them. The Text tab can be chosen all the while.
What now?, beside an error in the Problems panel, asks what you want to do about it: change the document or change the schema. Each answer is shown as the edit it would make and is offered only where it was tried and settles the error. It answers for data documents of every format, for record files and CSV tables, for a text that cannot be read (a comma too many, what was left open), and for some errors in a schema itself, such as a reference to something that is not there.
Writing a value replaces exactly that value in the text: the layout, the comments and everything else you typed are left as they stand. What is written is what the syntax needs — a JSON string is quoted and escaped, a number stays a number as long as what you type still reads as one, XML text and attribute values are escaped. Enter writes, Escape puts back what the document says. The buttons beside a row or on a card change the shape of the document: + adds another item to a list (the last one written again, values and all, which is what “another one of these” means), + adds a part you name — begin the name with @ for an XML attribute — and × takes a piece out, with the comma or the line that held it. What the schema says is wrong is marked where it is — a red outline round the cell, the row or the card, with the reason when you rest on it — and a problem in the panel below takes you to it, opening the way down to it if it is folded away. While you type, what the schema makes of the value is said there and then: a short pause after the last keystroke, the field is outlined and says what is wrong with it — the type, the bounds, the length, the allowed values, the pattern in the dialect of the schema — judged exactly as the document itself is, so a field never says one thing and the Problems panel another. It is never refused: what you type can always be written, as text can always be edited. A document that cannot be read has nothing to show, and the Data view says so instead of guessing. For the commonest errors, “What now?” beside the problem asks what you want: change the document, or change the schema, each shown as the edit it would make. A way is only offered if it was tried and really settles the problem.
A record file has the Data and Diagram views too, once it is paired with its record schema: the schema says what each line holds, so the grid shows a table of records for each record type — the records within one under its row, each record type that may stand there listed even before it has any — with a column per field, and the diagram draws the same as cards. A value is written in its field’s own characters, padded as the field pads it, and nothing else of the line changes. A value that does not fit is not written: one longer than its field, or no value of the field’s kind — a word in a number, a date not written as its picture, more decimals than the field holds — is refused with a message saying why, the file left as it was, and the field says so while you type. Nothing is ever cut to fit. What says what a record is cannot be changed here: the field at the record code’s place, the field that chooses a variant, a count another part’s repetitions or length follow, the record’s own length, and the repetitions of a group show greyed and dashed; change them in the text, where you see what follows from it. + adds a record holding its code and nothing else, after the last one of its type, and × takes a record out together with the records within it. Where the record type is read several ways — it has variants — the + is a list instead: choose the variant by name, and the new record holds that variant’s code in its choosing field, which you cannot change afterwards. In a file of records in blocks or segments (RDW with blocked or spanned), the descriptors that count them are written again when a record is added or taken out: a block left empty goes, a record added stands in the block of the record before it — in segments where the schema gives segmentLength — and every other block stays byte for byte as it was. Only a file whose block descriptors cannot be read to its end keeps its records; add and remove those in the text. The browser edits files of up to 10 000 records here: a larger file is shown in both views, a line above it says so, and it is edited in its text. The desktop edition, with a licence in force, sets no such limit.
Checking
Three things about reading XML the standards leave to the reader, and Settings › Advanced settings › XML offers both answers to each. Which edition of XML 1.0 decides names: the fifth (2008), the default, lets a name hold nearly any character; the four before it list the letters of Unicode 2.0 one by one, so a name such as <ſ/> is refused when you choose Earlier editions — for a document that declares version 1.0; XML 1.1 keeps its own rule. Read without Namespaces in XML: XML 1.0 itself lets a colon stand anywhere in a name, and *Namespaces in XML* is a second standard on top; on, <a:b:c/> or a prefix nobody declared is no error — but such a document is not validated against an XSD, which is defined over namespaces. Report optional errors: XML calls some mistakes errors a reader may report or let pass — a DTD content model that can match an element two ways, an xml:space other than default or preserve, a relative namespace name, a # in a system identifier, a predefined entity such as lt declared as something else, an entity used and never declared where only a validating reader must say so, and a version the earlier editions do not know; off, they pass, and on, the document is refused with the rule it breaks. Where XML makes a mistake fatal, no setting lets it through. Each choice checks every data document again, and the command line has the same three as --xml-edition, --xml-namespaces-off and --xml-optional-errors.
A data document is checked when it is opened, when its tab is shown and about half a second after you stop typing. A document with a schema is validated against it — JSON against a JSON Schema, XML against an XSD: every problem is underlined and listed in Problems with its place in the document (such as /address/city), and Show in schema shows the part of the schema it comes from. The status bar says Valid or Not valid — or, without a schema, Well-formed or Not well-formed. Revalidate checks it at once. A document is never shown as checked when it was not: where its schema does not say which version it is and none has been chosen yet, where the schema cannot be read, or where it is not in the workspace, Problems says so — *Not checked against untitled.xsd: the schema does not say which version it is…* — and the status bar says Not checked against its schema. Choose the version in the schema’s own tab (Revalidate there, or its diagram) and every document paired with it is checked again. An assertion (xs:assert, xs:assertion) of a schema read as XSD 1.0 is not run, since 1.0 has none, and the document’s Problems says so as a warning at the first element it was not run for. The same holds for every other XSD 1.1 construct such a schema sets aside, and the document is checked as an XSD 1.0 checker would check it, as though the construct were not written: a type table (xs:alternative) and the schema’s defaultAttributes, open content (xs:openContent, xs:defaultOpenContent), xs:override (the part it would replace stands as first written), the facets xs:explicitTimezone, xs:minScale and xs:maxScale, a wildcard’s notNamespace and notQName, targetNamespace on a local declaration, xpathDefaultNamespace, an identity constraint written with ref, the types 1.1 added (xs:dateTimeStamp and the rest, whose values are then not checked) and what 1.1 allows in an xs:all (a wildcard, a group, or an element more than once). Each is said once for each place it is written, as a warning at the first element or value it would have applied to; where one declaration carries several identity constraints, the warning says which one it is about, such as xs:unique[2] — the second xs:unique of that declaration. An xsi:type in the document that names a type 1.1 added (xs:dateTimeStamp, say) is an error at 1.0, and Problems says that it is the version that has no such type.
- Types, required and allowed properties (also pattern properties and property names), bounds (with exact decimals:
0.07is a multiple of0.01) and lengths, patterns, allowed values andconst, lists (items, uniqueness, what they must contain) and combinations (all of, any of, one of, not, if/then/else) are checked, by the rules of the schema’s version (in draft-04, draft-06 and draft-07 keywords next to$refare ignored; from 2019-09 on they apply); references are followed, also into other documents of the workspace. - What is left over (
unevaluatedPropertiesandunevaluatedItems, from 2019-09 on) is checked too. These two do not ask what the schema object they stand in allows, but what nothing in it — not its own keywords, not what its$ref,all of,any oforif/then/elsereach — has already looked at. A part of a schema that did not hold has looked at nothing, so what it named is still left over; and a property looked at somewhere deeper in the document says nothing about the one of that name at this level. - Patterns are checked in the dialect of the schema. A pattern that risks very slow matching is reported where it is written; when values are checked it is run under a budget.
formatis checked for the formats the version defines (dates and times, e-mail addresses, host names, IP addresses, URIs, UUIDs, JSON pointers, regular expressions, …); a mismatch is a warning, since in JSON Schemaformatis first of all a description — and an error where the schema asks for it, by naming in$schemaa metaschema whose$vocabularytakes in 2020-12’s format-assertion vocabulary.- A schema may say which of its own keywords are checked. From 2019-09 on,
$schemanames the *dialect* a schema is written in, and that document’s$vocabularysays which groups of keywords the dialect is made of. A dialect that leaves the validation vocabulary out asks nothing of a value — the types, the bounds, the lengths, the patterns, the required properties all stand in the schema as descriptions, and onlyproperties,all of,if/then/elseand the rest that apply other schemas still apply. This is rare and deliberate; a schema whose$schemanames one of the drafts’ own metaschemas, or a document nobody has, is checked in full as always.
In XML, the document element must be declared as a global element of the XSD — or, where Starts at names a declaration, it is checked against that one. For every element its attributes (declared, required, prohibited, fixed values; the four xsi: attributes — xsi:type, xsi:nil, xsi:schemaLocation and xsi:noNamespaceSchemaLocation — need no declaration, and a schema that declares one anyway may ask for it with use="required", which is obeyed: the attribute standing there is what satisfies it) and its content are checked: the order and number of child elements (sequences, choices, all groups, group references, xs:any), text only in mixed content, xsi:nil only where nillable, and simple values — the built-in types (numbers, dates, names, …), lengths, bounds, patterns, allowed values, lists and unions. Types are followed into other documents of the workspace. Places are written like /order/item[2]/@qty.
- Keys and uniqueness (
xs:key,xs:unique,xs:keyref) are checked with their selectors and fields: duplicate values, missing key values, references to a key value that does not exist, and fields that select more than one value. Values are compared by type, so01and1are the samexs:int. A key does not reach into content the schema says nothing about: a selector is a path through the document, so it passes through anxs:any processContents="skip"as well — but what stands inside one is not held to the key, because the schema disclaimed it. An element there with no key value is nobody’s fault, and two of them with the same value are not a duplicate. An attribute is disclaimed the same way: one that only anxs:anyAttribute processContents="skip"let in has no type, so a field naming it finds no value to compare — which is a missing key value, not a value. And because the three kinds share one set of names across a whole schema, two documents brought together by anxs:include, anxs:redefineor anxs:overridemay not each declare a key, unique or keyref of the same name in the same namespace. xsi:typeswitches an element to another type — also one from another schema of the workspace — which must be derived from the declared one. Elements of a substitution group may stand in for its head, also through several steps; a member without a type of its own takes the head’s. An abstract element is refused: one of its substitutes must be used.- An XSD 1.1
xs:assertis checked: the rule it writes in XPath must be true of the element, which is shown the way the schema reads it —@from le @tobetween two dates compares two days, and between two pieces of text compares two pieces of text. The rule sees the element on its own, so it cannot look at the element’s parent or its neighbours. A rule that goes wrong on the values it meets — comparing a date to a number, say — counts as not met; a rule the schema wrote so badly that it cannot be read at all is a fault in the schema, and your document is not called wrong for it. - An XSD 1.1 element may also carry a type table:
xs:alternativeentries that look at the element and choose which type it is to be checked against — the first whose test is true, or the one written without a test. The test looks at the element as it stands, since it is deciding what the element is;xs:erroras the type means this combination may not occur at all. An alternative may name a type or write one out on the spot, and either way the diagram shows it: a card per alternative, labelled with the test that chooses it. An attribute markedinheritablecan be read by a test on any element inside it, so an element can be told by its surroundings what it is to be. Both of these belong to XSD 1.1: a schema read as 1.0 is judged by its declared types alone. - A content model has to be followable without guessing. If two of its parts could both match the same element — the same name twice in a choice, an optional element followed by another of the same name, an element beside a wildcard that admits it — then nothing in a document could say which was meant, because the answer would depend on what comes after. Order and counts settle most of it:
a, ais fine, and so isatwice over followed by one more. XSD 1.1 is the gentler of the two here: where an element declaration and a wildcard could both match, the declaration wins, so the two never clash. - A schema itself is judged as well, and not only the documents it checks. A type written as a restriction of another must really be one: everything it accepts, its base must accept too. So a restriction may narrow an element’s type, ask for more of something, or leave out what the base allowed none of — but it may not rename an element, widen a range, turn a sequence into a choice, change a value the base fixed (or leave it unsaid), allow what the base forbade standing in an element’s place, or put an element where the base’s wildcard would not have allowed its namespace — which follows
formandelementFormDefault, since an unqualified local name is in no namespace at all. Where it does, the problem names which of those it is. Brackets do not count: a sequence holding one thing is that thing, and a part writtenmaxOccurs="0"is not there at all. A base in another document, or a type this editor cannot find, leaves the question open rather than marking your schema wrong. - In XSD 1.1 that question is put a little differently, and more generously: what counts is that every document the restriction accepts, the base accepts too — not that the two are written in the same shape. So where the base is an
xs:all, which says nothing about the order its members stand in, a restriction of it is judged by counting: how many of each element it can come to, and whether that is what the base allows. Anxs:allmay then be reordered, or written as a choice or a sequence, as long as the counts still fit — and two elements that may each stand in a third’s place both count towards it. Where the counting cannot be done — a wildcard is in the way — the stricter reading stands. - A type may also leave room for elements it never named:
xs:openContentsays that besides what its content model asks for, other elements may stand there too — anywhere among them (interleave) or only after them (suffix). Which ones is a wildcard like any other, so the same rules about names and checking apply. A schema can give every one of its types the same room at once withxs:defaultOpenContent, and a type turns that off again by sayingmode="none"for itself. The content model still has to be satisfied: room beside it is not room instead of it. - Where an
xs:anywildcard stands, what it lets in is checked against that element’s own declaration — unless the wildcard saysprocessContents="skip", which means look at nothing. The lengths ofNMTOKENS,IDREFSandENTITIESare counted in items, since those are lists; forxs:QNamethe standard leaves the unit undefined, so a length written there is not enforced. - Where a declaration stands decides what may be written on it.
abstract,finalandsubstitutionGroupare about a declaration others may point at, so they belong at the top of the schema;use,minOccurs,maxOccurs,formandrefare about how a declaration stands *inside* something else, so they belong there. A type written inside a declaration is that declaration’s own and cannot carry a name. - A facet has to make sense for the type it constrains, and which facets those are depends on what the base turns out to be — which is followed through named types, not only read off a built-in. A list can be asked how long it is and what its written form looks like, never how large it is; a union can be asked almost nothing at all, since a value of one may be any of its member types and a bound would mean something different for each. And a facet is said once: a type cannot have two lengths.
pattern,enumerationandassertionare the exceptions — a value must match every pattern, be one of the listed values and satisfy every assertion — so writing several of those is writing one thing. - Facets that contradict each other are reported as well, since together they describe a type nothing could ever be of: a
lengthwritten beside aminLength(one says exactly, the other at least), a minimum above its own maximum, an edge said both inclusively and exclusively, or more digits after the point than the type allows in all. - XSD 1.1 adds
xs:precisionDecimal, a number that remembers how precisely it was written:2.0e-3keeps its trailing nought where an ordinary decimal would read the same text as0.002and forget it. It takesminScaleandmaxScale, which say how far right of the point a value stands. - A wildcard says which names may stand where it does, and that is read as a set:
##anytakes everything,##otherevery namespace but the schema’s own, a list takes the ones it names, andnotNamespacetakes everything but the ones it names. Two such sets can then be compared — whether one allows no more than another, and whether two of them overlap — which is what a restriction and an ambiguous content model are judged on. An element it does not admit is simply not expected there, and is reported as that. Anxs:anyAttributesays the same about attributes, and says it the same way. A wildcard may also say what it leaves out —notNamespaceby namespace,notQNameby name, andnotQName="##defined"for everything the schema declares globally — how you say “anything but what I already have declarations for” — andnotQName="##definedSibling"for everything named in the content model it stands in. A name is a namespace and a local part, so anotQNameis read with the schema’s own prefixes:t:heldand plainheldare two different names, however alike they look. - What a schema writes on an attribute is judged too. An attribute the standard gives a few words takes one of them and nothing else — and the lists differ in ways that are easy to get wrong:
finalon an element may sayextensionandrestrictionbut notsubstitution, whichblockon the same element may.#allstands on its own, since it already says everything the list could, and an empty list is a list of nothing, which is a fine thing to say:block=""blocks nothing at all.true,false,1and0are the four ways XSD writes a yes or a no, and nothing else is one. - What a component calls itself is a name without a colon in it. A name with a colon names a namespace, and a component does not get to choose which namespace it stands in — the schema’s
targetNamespacesays that. Sofoo:baris not the name of anything, and neither is an empty one. What is written as arefis a different matter: that points at something else, and may well carry a prefix. - A name the editor cannot find is not always an error. A schema that names a type it does not (yet) hold is *incomplete*, and an incomplete schema is still a schema — which is the state every schema passes through while you write it. So a
type, asubstitutionGroup, a list’sitemTypeand a union’smemberTypesthat reach nothing are warnings: the diagram stays unlocked and the document is still yours to save. Abaseand arefare errors, because a type whose base is missing cannot be built at all and arefhas nothing to stand for. Where the missing name *is* needed, it is said: a document whose element or attribute has a type the schema does not define is reported as not valid, rather than passing because there was nothing to check it against. A name that could never be a name (type="123", an emptyitemType) stays an error too, and so does one whose prefix the schema never declared. - An XSD 1.1 `xs:assertion` is checked too, and it is a different rule from
xs:assert: where that one is about an element, this one is about a value, and the value is what it is shown — written$value, and typed the way the schema reads it, so$value mod 2 = 0is arithmetic andcount($value)counts the items of a list. A rule written on a list’s item type is asked of every item; one written on a union is asked of the value as the member that accepted it reads it; and the rules of a type and of the type it narrows must both hold. Because such a rule is about a value and not about a place in your document, it cannot look at the document at all: an expression reaching for the element it stands in (.) is never satisfied, which is what the standard asks for. - A rule may ask what the date is —
$value lt current-date(), for a date that must have passed. It is answered with your computer’s clock, and the same moment is used for every rule in one check, so a document cannot be judged against two different “now”s. - Not checked in XML (yet): a rule that asks where the document came from (
base-uri()), which is a thing a value cannot know. The facetstotalDigits,fractionDigitsandwhiteSpaceare checked, and this line said they were not for several releases after they began to be.
Suggestions from the schema
In a JSON document with a schema, Ctrl+Space — or just typing — suggests what the schema allows where you are: the property names of the object (required ones first, with their type and what the schema says about them; names already there are left out), and the allowed values of a property or item (listed values, true/false, null, and the schema’s examples and default). Choosing a name also adds the start of its value. When the schema offers alternatives (one of, any of), the names already in the object choose between them: once a name is written that only one alternative allows, the other alternatives’ names are no longer suggested. Names that no alternative knows, such as the document’s own $schema, do not count; while nothing decides, the names of all alternatives are suggested. References, conditions (if/then/else), pattern properties and tuple items are followed too.
In an XML document with an XSD, typing < suggests the elements that may come next — only those the content model allows after the elements already there, required ones first; choosing one also adds its end tag. Names are written with the prefix the document binds to their namespace (ns2:roleKindId); an element whose namespace is not declared yet gets an xmlns declaration. In a start tag, Ctrl+Space or typing suggests the attributes not yet written (required ones first); choosing one adds ="" and suggests its values. For an attribute value or the text of an element, the listed values, true/false, a fixed value and the default are suggested. Namespace declarations on the start tag you are writing count too. An abstract element is not suggested; the elements that may stand in for it are.
File › Download (Ctrl+S) saves the data document shown; Download all (.zip) includes the data documents of the workspace, and they are kept in the browser with the rest of your work.
Standard packs
A standard pack knows one kind of message — a standard such as HL7 v2, or a format of your own — on top of a schema format Schemantix already reads: which messages there are, how a file is known to be one of them, what each field is called in plain words, what each code means, and what a message is for. Packs come with Schemantix, and you can open your own.
Recognising a file
- When you open a file that names no schema and that no schema of the workspace reads, the packs in use are asked. A pack knows its messages by the characters a file starts with, by a pattern its first line matches, by what a member of a JSON file’s top object holds (FHIR’s resourceType), by an XML file’s element and its namespace, or — where it says none of these — by the file’s name. A message may be written in more than one way — as JSON and as XML — and a file is read through the definition of the way it is written; a definition that imports other files of its pack opens with them. Where many messages share one definition, a file is checked from the place in it its message names. The one message that recognises the file pairs it with that message’s definition, which opens in the workspace under packs/. Two that both recognise it are left to you, as any file nothing knows is.
What a pack tells you
- In Node details, a field of a pack’s definition shows its readable name and what it is for, in your language.
- In the Grid, a field whose values come from a table of the pack shows what each code means beside it (N — New). A code that is not in its table is a warning, not an error: standards’ tables are often extended where they are used, so check that the receiver knows the code.
- A pack may bring a focus of its own, which joins the list under Settings › Focus.
- A pack may bring examples of its messages: open one from Settings › Advanced settings › Packs and sources, under the pack. It is opened as a file of the workspace and recognised as any file is.
- A table may hold a pattern for a kind of code as well as codes — HL7’s table 0396 holds HL7nnnn, which every HL70063 is. A code a pattern matches is in the table; the grid shows a meaning only for a code the table lists itself.
HL7 v2
- The HL7 v2.5.1 pack comes with Schemantix, whole — in the browser fetched once with File › Standards… (since 1.229.0), on the desktop and the command line carried: every message structure, segment, field, component and data type of the standard, and HL7’s code tables with what each code means. Every name, title and meaning is in English and Dutch. HL7 v2.3, v2.3.1 and v2.4 have packs of their own (since 1.268.30), fetched and carried the same way: a message is checked against the version its MSH-12 names, and v2.5.1’s pack takes every version that has none of its own.
- A message is known by its first segment, MSH, and the message type in MSH-9: by the structure it names (ADT^A01^ADT_A01), or else by its event (ADT^A04 is checked as ADT_A01). Every field and component is checked, how often each stands, and each code against its table.
- Fields are named as the standard writes them, PID.5.1, with their readable name in Node details (Family Name). The HL7 v2 messages focus shows the grid, the Ruler and the problems first.
- Fields beyond a segment’s last, components beyond a field’s last (a fifteenth part of PID-5) and subcomponents beyond a component’s, and a segment of a site’s own (Z…, such as ZPI) are read past, as the standard asks of a receiver: empty ones say nothing, others are a warning. A message of another version than 2.5.1 is a warning at MSH-12, and is still checked against 2.5.1.
- A file of several messages, or a batch between FHS/BHS and BTS/FTS, stays one document: each message is checked against its own definition, each problem says the message it stands in (“message 3, /PID[1]/PID.3”), and the batch’s counts are checked. The Grid and Diagram show one message at a time — the one the cursor stands in when you switch to them; choose another under Message above them. A value written there lands in that message.
- An anonymised copy of a message keeps to the pack’s profile: its header and its codes stay, its names are made up in Dutch, its dates are new ones, and every other value has each letter and digit replaced by another of its sort — so the copy is still the message it was. A masking file you choose instead wins.
- Data › Write this document as HL7 v2 XML encoding writes a message as HL7’s XML encoding of version 2: the message structure the root, a segment by its code, a field by its name (PID.5), a component by its data type (XPN.1), and empty parts left out. A document of that encoding is written back with Write this document as HL7 v2 message (ER7), recognised again and checked; on the command line
schemantix convert <message> --to v2xmland--to er7. Both are stylesheets the pack brings. - Data › Make the acknowledgement (ACK) of this message writes the ACK a receiver would send back: the sender and receiver swapped, MSA AA where the check found no error and AE where it did, and an ERR for every finding — the segment, which of its kind it is, the field, HL7’s error condition (such as 101, Required field missing), and whether it is an error or a warning. On the command line
schemantix convert <message> --to ack. - Data › Write this message as FHIR R4 (a Bundle) writes a message as HL7’s v2-to-FHIR guide maps it — every ADT structure (ADT_A01, A02, A05, A06, A09 and A17, and the events that share them) and ORU_R01: one Bundle, a transaction, in FHIR’s JSON — the message header, the patient, the visit, next of kin, allergies, diagnoses, procedures, insurance, an order’s report with its observations and specimens, and every practitioner, organisation and location the fields name, each an entry of its own that the others refer to. It opens beside the message and is checked as any FHIR resource is. Where the guide leaves a value FHIR requires unfilled, the Bundle says so when it is checked: nothing is made up. On the command line
schemantix convert adt.hl7 --to fhir. The mapping is a pipeline written from HL7’s guide, exported as a stylesheet the pack carries: Settings › Advanced settings › Packs and sources › Open a mapping as its pipeline opens it in the pipeline editor, with the message’s definition and FHIR’s XSD, to read or to change (on the command lineschemantix pack mapping hl7v2 fhir ADT_A01 --into <folder>). - Generate data from a message’s definition writes messages that hold: MSH-2 holds the separators, MSH-9 the message’s own type, codes come from their tables. Messages that each break one rule break that rule; the command line writes them with
schemantix generate --message ADT_A01 --invalid, each named after its message (ADT_A01-1.hl7).
FHIR
- The FHIR R4 pack comes with Schemantix — in the browser fetched once with File › Standards… (since 1.229.0), on the desktop and the command line carried: every resource of HL7 FHIR Release 4 in JSON and in XML, checked as the standard’s own JSON Schema and XML Schema check. Since 1.186.0 the pack is one set (fhir-r4.set.json), laid out as that JSON Schema where it is loaded — the same verdicts, but that a list where one object belongs is refused, as FHIR’s JSON asks. A JSON file is known by its resourceType and checked from that resource’s definition (#/definitions/Patient) — not against all of FHIR at once; an XML file by its element in FHIR’s namespace, and checked against FHIR’s XSD and the XHTML schema it imports.
- Every element is named by its path, as FHIR writes it (Patient.contact.name, Observation.value[x]), in both languages; what it is for is FHIR’s own explanation, in English: its short description, its value set and how strongly it binds, what each code means where FHIR says more than the code, and FHIR’s comment. A code of a required binding outside its value set is an error, as FHIR asks.
- The pack brings an example of every resource that R4 has one of, and the FHIR resources focus: the text, the diagram and the problems first.
- On the command line
schemantix validate patient.jsonrecognises a resource as the browser does; a folder of resources is checked with the schema read once. - A resource in FHIR’s XML is offered Write this resource as FHIR’s JSON under Convert: the same resource as FHIR writes it in JSON — each repeating element a list, numbers kept as they were written (10.00 stays 10.00), extensions of a value beside it under its name with an underscore — opened beside it and checked again. On the command line:
schemantix convert patient.xml --to fhir-json. - A FHIR profile — a StructureDefinition that narrows a resource, such as nl-core’s nl-core-Patient — opens as a schema of its own: the diagram shows each element with its cardinality, its type, its fixed value and FHIR’s description, a slice beside the element it slices (identifier:bsn), and the node panel its pattern, binding and invariants. Change it there — make a part required, leave one out, set a fixed value or the most repetitions — and it is written back into the profile’s snapshot and differential. A resource opened beside it is checked against it: every element the resource has against its cardinality, types, fixed and pattern values, slices, bindings and invariants.
- A profile may be written in JSON or XML, and with its snapshot or as a differential alone — what it changes of the definition it builds on, which is then made whole from that definition (R4’s own come with the application, in the browser too). Beside cardinality, types, fixed and pattern values, slices, bindings and invariants, a value is held to the least and greatest value and the longest text its profile allows, and a reference to the kinds of resource it may point at.
- A profile opened from a pack and changed is yours; File › Back to the pack’s version puts the pack’s back, as an edit you can undo. A resource that names profiles in meta.profile is checked against each of them, wherever a pack at hand carries it — and a profile no pack carries is said, a warning. The desktop carries nl-core and zib2020, each a pack whose messages are its profiles — since 1.190.0 a layer on FHIR R4 (nl-core on zib2020), each profile a message of the layer with what a layer can say of it, and the profile itself beside it, checked as before. schemantix pack layer reads a FHIR package of your own into such a layer, and since 1.221.0 File › Save as FHIR package… (or schemantix pack package) writes a layer on FHIR R4 back as a FHIR package for other FHIR tools: each message of its own a profile with its differential, its code lists value sets, and the package it was read from with it; what no profile can say is left out and said. In the browser, open nl-core — or any FHIR package — with File › Open pack or set (zip, FHIR package or .set.json)…: the .tgz as packages.fhir.org hands it out is read as a pack of your own and kept for the next time.
Your own packs
- File › Open pack (folder)… or Open pack or set (zip, FHIR package or .set.json)… opens a pack: a folder with a pack.json that names its messages, definitions, tables, names and explanations. What is wrong with it is said file by file; a pack with an error is not used until it is mended. A pack you opened is kept for the next time. On the desktop, File › Get a set… takes a path on the computer or a URL and opens the set, zip or FHIR package there as the pack it makes — a path in the open dialog, for you to confirm; in the browser a set is uploaded instead. File › Standards… (since 1.226.0) lists the sets each source offers — the Schemantix site, and the sites you add under Settings › Advanced settings › Packs and sources › Sources of standards, each switched on or off (an address over https; plain http only for a site on this computer) — with whether each is built in, fetched (and so there offline), there in another version, or not here: Fetch gets it and keeps it, a layer with the set it is laid on; Remove lets it go; Open a set of your own… opens one you have. Zib2020 and nl-core, the Dutch layers on FHIR R4, are fetched there. On the desktop, which carries the standards itself, the Schemantix site is not among the sources (since 1.230.0). A document whose set is not here is recognised all the same (since 1.228.0): a bar over the editor says whose document it is, and Fetch gets the set at once and reads the document through it — never without your asking; Not now lets it go. A pack may also be one file, a set (.set.json): its layout, a library of the parts its messages share, its messages, tables, names and explanations together. A set describes record files, JSON documents ("written": "json") or, since 1.213.0, XML documents ("written": "xml"): each field an element — or, saying "as": "attribute", an attribute — in the set's namespace, a part's parts in order, as a choice or in any order; its documents are checked by the set written as one XSD, which also makes their example documents and is what the set is converted as. In its Grid (since 1.214.0) an attribute is marked @ and each field says what it stands as; the set's Namespace stands over the table, and Node details says under XML whether a field stands as an Element or an Attribute (a value standing at most once may; what cannot is greyed out), the namespace it is in, and of a group the Order of its parts (Fixed, Choice or Any order) and whether text stands between the elements. An XML document paired with the set stands In the sample beneath the grid: choose a value there and its row is chosen; choose a row and its value is marked. A field may be in a namespace of its own — an extension’s element or attribute — given in Node details under XML (since 1.222.0): the set is then checked with an XSD of that namespace beside its own. A rule of such a set that is a warning or a note makes no document wrong, and is said as one, in its own words, when a document is checked (since 1.220.0). File › New › A set from an XSD (since 1.217.0) — or Open as a set… on the right-click of an XSD’s tab (since 1.231.0) — makes such a set of an XSD in your workspace, with what it includes and the rules of its Schematron — the one beside it (its name with .sch), another, or none: tick which root elements become messages, and see, before Make the set, what each kind of construct becomes, how many there are, and whether it fits, is adapted or is not taken over. Afterwards the same stands under Problems of the XSD and of the Schematron, each at its place. On the command line: schemantix set-from-xsd policy.xsd. Open the folder or the zip that holds it as a pack and it is used as the pack it makes; open the file itself as a document and it is a schema like any other, shown and changed in the text, the diagram and the grid — and Node details says each part by the set’s own name and explanation in your language, as it does for a pack. A layer — a set that names its base and holds only what it changes — is shown in its Grid as its base with the layer laid over it, each message, part and field marked Base, This layer or Changed, with what the layer says of it, and the layer’s changes in their order beneath. Its base is looked for among the sets of the workspace and of the packs you opened; where it is not at hand, or a change cannot be made, the grid says why. A layer is changed in its Grid: the table, where whether a field must be there and how often a part stands are chosen — *Any number of times* is unbounded — each choice written into the layer as a change; click a row and Node details says it and changes it too, any other count under Other… — what would widen the base is locked, and a field the base requires cannot be made optional. Or change it in its text. A field of a set is optional unless it says "use": "required", and a part of a message occurs once unless it says occurs (**"0..*", "1..*"**).
- In a layer’s Grid a field or a part may also be left out — Not used, where the base lets it be absent — and a field given a Code list: a narrower list of the set, or, in Node details, only some codes of the base’s list ticked, which makes a list of the layer’s own. In its text a layer of a set of JSON or XML documents may also narrow a field’s bounds — "maxLength": 35, a least or most value, digits — never wider than its base’s (since 1.219.0). Node details of a message or a part of one adds a part of the library within it: which part, how often, and after which. Under Rules it lists the rules that stand on a message or a part — its base’s and the layer’s own — and Add a rule… says one of the layer’s own in the rule builder: a rule only narrows what the base lets through, and is taken back from the list of changes. A choice stands in its field at once, marked and closed while the layer is read again with it. A value chosen is what the layer says, and holds should its base change; As the base: … in the same field takes it out, so that the base is followed again. The changes are listed under the table, each with Take back. A layer’s base may itself be a layer; each row then says which layer beneath changed or added it. A part several messages share — a segment of the library — gets the column Applies in: a change of it applies in all messages, or, ticked in Node details under Where this change applies, only in some. Neither changes the base; the layer writes which messages it means (
"in": ["ORDERS"]). A component of a field — EVN.5.2.3, a part of a type such as HL7’s XCN — is changed where it stands: in this field only, not in every field of that type. A layer’s Diagram shows the same set: what the layer adds framed in orange, what it changes framed dashed, a field it leaves out struck through. Each card carries the readable name and the explanation the set gives it — the explanation whole when you point at it. Click a card to change it in Node details. Open the base opens the set a layer is laid over, where it is a document of your workspace; a set that layers build on says so over it, and Make a copy to work on gives you one under a name of its own that no layer is laid over. A large set is worked on in part: a layer over one (more than 40 messages, as HL7) opens with its messages or its parts as tiles, in groups — click what you work on and Open. Where the set groups its messages itself (messageGroups, each message’s messageGroup — chosen in the set’s grid under Kind, and + group makes one, titled in English and Dutch), its tiles and cards stand in those groups, the messages in none together last; a layer takes its base’s groups, and may title one anew or add its own. Point at a message’s tile — or reach it with the keys — and it is drawn small beside the tiles: its parts and groups, how much each holds, and where the layer changes something. Click a group there and Begin at ORDERS › SG25 opens the working set at once, the grid and the diagram at that group. Only that is read and shown; the rest of the layer stays in it, is still checked against the whole set, and is counted above the grid as sleeping. Choose the working set… changes it, and The whole set shows all of it, more slowly. A part of your own — a segment or record type the standard has not — is made with + New part in the library in the layer’s grid, or with A new part… where a part is added to a message: its name, the code its lines begin with, and its fields; each field is placed after the one before it, and where it stands is said as you type. A set itself — one that is no layer — is one table in its Grid: its messages with their parts, then its library with each part’s fields. Change whether a field must be there, how often a part stands, a length (the fields after it move along) or a description in its row; rename a message, a part or a field in its name — every part of a message that is it, its rules and its readable name and explanation follow — and choose what a field holds, and a code’s list among the set’s; a part’s variants — what a line holds where a field of it says a code — are a row each, their fields beneath; Code lists beside Table shows the set’s lists, each in a grid of its own: its title, version and whether values are checked against it, its codes with what they mean in English and Dutch — made with + Code, renamed and changed in place, taken out with ✕, or pasted as Excel’s two columns — and the fields that hold to it; + New makes a list with its first code; add a field (+ field in order, from position 31), a part to a message, a message, or a part of the library where it belongs; ✕ takes a field out and moves the rest back. Types beside them (in a set of composite types, as HL7’s XPN and CE) lists each type: open one to change its components — what each holds (a kind, a code of a list, or another type, whose components are shown beneath it), whether it must be there, what it says — and add one at the end, numbered on (+ component in XPN — becomes XPN.15). Over it is said in how many fields the type stands, the first named: a change holds in all of them; for one field alone, change it in a layer on the set. In Table a field of a type is the way to it (XPN — change the type). Each component has a readable name of the type’s own, in English and in Dutch (kept as XPN.2); where it has none, the name the first field of the type gives it is shown greyed (as PID.5.2: Given name). Where a sample is paired with the set, In the sample says of each field of the type what is found within it — how often, and on which line first — and how many fields keep to it. A layer of your own is begun with File › New › A layer on a standard: choose the set — HL7 v2.5.1, or one in your workspace — and it is made, named after its file, changing nothing yet. A set, guided (File › New › A set, guided) begins a set from a standard (a layer on it), from a sample file you have (a set proposed of it, the sample read through it beneath the grid — of an XML document a set of XML documents, an element of another namespace a field in that namespace, since 1.223.0; of a JSON or YAML document a set of JSON documents, its object the message, since 1.225.0) or from nothing (fields separated, or at fixed positions), and shows a light strip of steps over it — begin, structure, check, conditions, texts, download — each saying what it is for — Explanation folds that away, and Back, On to … and Turn the guidance off stand at the end of the steps’ line at every step; Turn the guidance off when you no longer need it. At Conditions the set’s conditions are listed in words — what must hold together, more than one field or how often something stands — each with whether the sample keeps to it, and where not, on which line; choose in the grid the part a condition is about, and begin a new one from a shape: If … then …, One of these fields, and, where the set can say them, Unique, Refers to and How often a variant. For a layer the conditions of its base are listed, and it may say more of its own in the same way. - Settings › Advanced settings › Packs and sources lists every pack with a switch: a shipped pack can be switched off, one of your own removed. Check the maximum lengths a standard gives its fields is off until you switch it on: many systems send longer values than a standard allows.
- File › Save as pack… bundles schemas of the workspace into a pack of your own: give it an id, a version and a title and description in English and Dutch, tick the schemas that are its messages (each of one format), and say for each what it is called, what it is for and how a file is known to be one (the names its files have, the characters they start with, or what a member of a JSON file’s top object holds). It asks in steps — The pack, Messages and recognition, Conditions, Names and explanations, Codes — each a click away in the list beside it. At Conditions each rule of the schemas chosen is listed: give one with no name a name, choose how heavily a finding of it weighs, and write what it says in English and in Dutch — the pack is not saved until every condition is said so. At Names and explanations you give each message’s record types and fields a readable name and an explanation, and at Codes say what each code of a code field means — a field given meanings names a table of the pack, and a code outside it is then a warning rather than an error. A pack of record schemas is saved as one set (<id>.set.json in the zip): its messages, the record types they share, the codes with what they mean, the names, explanations and conditions in one file. A pack of other schemas — an XSD, a JSON Schema — is saved as the schemas and a pack.json, and a condition’s message its format cannot keep is kept in the pack’s explanations under the condition’s name. The pack is checked as one you open is, and saved as a zip a colleague opens with File › Open pack or set (zip, FHIR package or .set.json)…. Where a pack of the same id is kept, the next version is proposed and what changed is asked, kept in the pack beside the earlier notes; and a pack opened while a later version of it is kept is not taken in its place. On the command line:
schemantix pack make draft.json --into pack.zip(or a folder), the draft the same answers in a file of JSON, each message naming its schema’s file. - Its texts follow what they are of. A pack’s readable names and explanations are kept by the name of what they are of — a message, a record type, a field (
order.number, orPID.5). When you rename a field or a record type in the diagram or the Ruler of a schema that stands in a folder with a pack.json, the keys of that pack’s files of names and explanations are renamed with it, wherever those files are open. A text whose key names nothing the pack holds — left behind by a rename, or written wrong — is said as a warning when you open the pack, and byschemantix pack check. A finding explained: an explanation may also be kept by a finding’s code (CODE_NOT_IN_TABLE) or by a field and a finding together (PID.3|REQUIRED_MISSING); a problem of one of the pack’s messages is explained under it in the Problems panel — by the field and the finding together, else the finding alone, else the field. - A pack may keep its standard’s segments and data types once, in a library; the definition of a message is made whole from it when the message is opened, and from then on it is an ordinary schema.
- On the command line the shipped packs are there without a word:
schemantix validate <file>recognises an HL7 v2 message and checks it against its definition, andconvert,transform,queryandanonymiseread it through that definition.--pack <folder|zip>adds a pack of your own,--pack-off <id>leaves a shipped one off, and--message <name>says which message a file is where it is not recognised.schemantix pack listnames the shipped packs,schemantix pack check <folder|zip>says what is wrong with a pack. A file of several messages, or a batch between FHS/BHS and BTS/FTS, is read there message by message: each checked against its own definition and each finding said with its message (“message 3, /PID[1]/PID.3”), the batch’s counts checked, and anonymised, converted and acknowledged a message at a time. - A message may also be recognised by bytes at a place (
"bytes": {"at": 0, "hex": "F1 F0 F0"}in the pack), for a mainframe file in EBCDIC whose text shows nothing a pattern could read; its definition then says the code page it is read in.
The text editor
The text editor is always editable, whatever state the document is in — errors never lock you out of the text.
Suggestions
Press Ctrl+Space — or just start typing — for suggestions of what may be written at the cursor. Use the arrow keys and Enter to choose one, Escape to close the list.
- In JSON Schema: the keywords of the document’s version that the object does not have yet, with what each one holds (a schema, a list of schemas, text, a number, …).
- In XSD: the elements allowed inside the current element, and their attributes.
- In a pattern — a JSON Schema or OpenAPI
pattern, anxs:pattern’svalue, a record field’spattern, an SCML field’spattern— the names that may follow\p{or\P{, and only those the pattern’s own language knows: XML Schema’s blocks (IsBasicLatin) and categories in an XSD, ECMAScript’s categories,Script=and properties in a JSON Schema. JSON’s doubled backslash ("\\p{Lu}") and YAML’s quotes are read as the schema means them. - Fixed values, such as the types and formats of JSON Schema or
use,formandprocessContentsin XSD, andtrue/false. - Where a reference is written (
$ref,type,base,ref, …): the definitions of the document, written the way the document writes them (#/$defs/Address,tns:Address), followed by the built-in types (xs:string). - In a data document with a schema: what the schema allows at the cursor (see “Data documents”).
Choosing a keyword or attribute also inserts the start of its value — {}, [], "" or ="" — and shows the suggestions for the value straight away.
Suggestions come from the last version of the document that could be read. A document that has never been valid gets them once it has been.
Checking while you type
About half a second after you stop typing, the text is checked: problems are underlined, marked in the margin and listed in the Problems panel, so you see straight away whether it is right. Revalidate in the Problems panel does the same on request. In XML, typing in the name of an element’s opening tag changes its closing tag too, and the other way round. The diagram only follows when you switch views, and if the version of the document is unknown you are only asked about it when you revalidate or switch.
Changing the schema from the text
Right-click anywhere in the text and you get the same menu the diagram’s cards offer, for the piece of schema you clicked on: Rename…, Make named type…, Remove, and whatever else that node allows in this version of the format. The menu is about the innermost thing the click landed on — click the name of an element written inside another and it is that element you are renaming, not the one around it.
What the menu changes is the schema itself, so the document is written out again afterwards and the cursor stays on the piece you were working on. Entries that only change how the *diagram* is drawn (expanding, collapsing, choosing a starting point) are not offered here: there is no diagram on the screen to show them.
While the schema has validation errors the entries are shown but greyed, with the reason under them: changing the schema as a whole is held back until the errors are gone — the same lock the diagram is under, and for the same reason. The text itself stays editable, so you fix them there and the entries come back.
The menu works on the document as it was last read, so if you have typed since, the text is checked first. Right-clicking never asks you which version the document is; only Revalidate and switching views do that.
Going to a definition
Hold Ctrl (on a Mac Cmd) over a reference you have written — a "$ref", or an XSD type=, ref=, base=, itemType= or one name in a memberTypes= — and it is shown as a link; click it and the cursor goes to where the thing it points at is written, with its name selected. F12 does the same for the reference the cursor is already on, and Go to definition in the right-click menu for the one you clicked on.
A reference into another document of your workspace opens that document’s tab on its text and puts the cursor there, so following a chain of references across files needs nothing else. A reference to a built-in type (xs:string) and one that points at something your workspace does not declare are not links: there is nowhere to go, and saying so by not offering the jump is clearer than a jump that lands nowhere.
Your browser may well open its own developer tools on F12 as well — that is the browser’s doing. Ctrl/Cmd-click and the menu entry are always available. An XSD substitutionGroup= is not followed yet.
Indenting
New lines are indented the way the document already is — with tabs, or with the number of spaces it uses. Tab indents the line and Shift+Tab outdents it. To move on to the next control with the keyboard, press Escape first and then Tab.
Lay out in the toolbar indents the whole document afresh — a document that arrived on one long line, or one whose indentation has drifted while you edited it. It works on whatever text editor is open: the schema, a data document on its Text tab, or a stylesheet. The indentation it uses is the document’s own, so a file written with tabs keeps its tabs. The command line does the same to a file: schemantix lay-out order.xml, with --indent tab or --indent 4 to choose the indentation and --out to write it to a file.
It changes whitespace and nothing else. Every other character comes out in the order it went in — attributes stay where you wrote them, the XML declaration stays as it is, comments, processing instructions and CDATA are untouched, and numbers and escapes are written exactly as they stand. Text an element holds is left alone altogether: xs:documentation, an xsl:text, a value in a data document, and anything under xml:space="preserve" keep their own layout, because their whitespace is part of what they say. One blank line is kept where you left one between two elements or two members. Whitespace here means spaces, tabs and line breaks: a no-break space between two elements is text, so the element around them is left as it stands.
Ctrl+Z takes a lay-out back in one step. If the document cannot be read at all, the button is greyed and says why — fix the syntax errors first. If it was already laid out this way, the status bar says so rather than leaving the press unanswered.
This is not the same as the tool writing the schema out itself. Switching back from the diagram after an edit rewrites the document in the tool’s own style — keywords and attributes in its order, its own XML declaration — while Lay out never does that. If you want the house style, edit something in the diagram; if you want your document back exactly as you wrote it, only indented, use this.
Ctrl+Z and Ctrl+Y (or Ctrl+Shift+Z) undo and redo typing in the text; the text has its own history, apart from the diagram’s.
Finding text
Type in the search field of the toolbar (Ctrl+F or Ctrl+K — also from within the text; what you searched before is selected, so you can type over it). The number of matches is shown next to it; Enter goes to the next match, Shift+Enter to the previous one, and Escape empties the field and takes the marks away. In the text, F3 and Shift+F3 go on to the next and previous match. Every match in view is marked, however it is written in upper or lower case — the one you are on in the colour of the selection, the others in the marker colour. Data documents are searched the same way. To change what you found, press Ctrl+H or the button beside the search field and type what it should become: Replace first goes to the next match and, pressed on a match, changes it and moves on (Enter does the same); Replace all changes every match at once. Upper and lower case are ignored, what you typed is taken literally, and Ctrl+Z takes a replacement back.
The diagram
Starting point
A diagram starts at a point you choose: the document root or a named definition (for XSD: a global element or type). The Start points are listed on the left; until you choose one, the diagram shows the same list under Choose a starting point. A document with one obvious start opens there at once.
Cards
- Each node of the schema is a card with its name, type, occurrence (for example
0..1or1..∞) and a summary of its restrictions. - The + button (top right of a card) expands one level; right-click for Expand or Collapse, Expand all below and Collapse everything below — and, on a card from another document, Open in ….
- References are followed: expanding a reference shows the referenced definition right behind it (dashed), separately for each place it is used. A reference back to something already open is marked recursive.
- Compositions (all of, any of, one of, not, sequence; an XSD choice shows as one of, an xs:all as all of) appear as small rounded cards between a node and its members; if/then/else hang off a condition card. Pattern properties, additional properties and similar are gathered under one “other properties” card.
- A node is named by its description where it has one (
xs:documentation,titleordescription), on the card’s first row, with the element or property name in its header beside it — and by the name alone where it has none. A description too long for a card is shortened; point at it to read the whole of it. - A name in a coloured tag shows a special position: items, pattern and additional properties, conditions and definitions.
- Red cards have errors; a lock means the card cannot be edited right now (see “Problems, errors and locking”).
Which way it grows
A diagram grows from left to right, one column per level. Turn on Diagrams from top to bottom in Settings › Display settings… to have it grow downwards instead: the children of a card stand in a row under it, as in an organisation chart. Only the cards that have children of their own stand side by side; the cards with nothing below them are stacked in one column under their parent, a little indented, so an object with fifty properties is no wider than one card. Their lines run down beside the column and come in from the side, since a line from above would cross the cards over them; a single card with nothing below it is no column, and its line comes in from above. The choice holds for the schema and the data diagram alike and for every document, and an export (Mermaid or SVG) is drawn the same way round — as is schemantix diagram --direction down.
What a node says
Click a card and Node details (on the right) opens with one sentence in plain language about it — for example “A list of 1 or more “line”; each one has a required amount (a number, 2 decimals) and an optional description (text, up to 35 characters).” An XSD says the same with totalDigits and fractionDigits: “a number, at most 9 digits, 2 decimals”. It is written from the schema itself, so it follows every change you make, and it is in the language the application is in. The same sentence opens every entry of File › Documentation.
Under the sentence, Use says whether a property is Required or Optional, and How often how many times a member of a sequence may stand: At most once, Exactly once, Once or more or Any number of times, each chosen in a list. Any other count — two to five times, say — is typed under Other…, the last choice of the list, which opens the fewest and the most right beneath it; a count of its own stands there already.
Below it, The standard’s terms folds open: the path, the types, the occurrences, the facets, the enumeration, the annotations — everything you edit a node with. It starts folded; open it once and it stays open.
Only the restrictions that have an effect are offered, and which those are is the standard’s answer rather than a guess from the value type: an xs:date takes a smallest and a largest value and an xs:string takes neither, although both are text. Where a node can take none at all — an XML Schema element whose type is a complex type, a record type — the panel says so in one line instead of showing you an empty list. In XML Schema, xs:pattern and xs:enumeration belong to a simple type; a complex type has nowhere to put one.
A node that declares more than one type says what that means and which restriction reaches which type. In JSON Schema the types are alternatives — a value is any one of them — and a pattern constrains only the text while a minimum constrains only the numbers, so each is labelled with the type it reaches. In XML Schema two types are the members of one xs:union, and a union is asked about as a whole: it takes a pattern and an enumeration, and no length and no bound, because its values have no single length or order to compare.
Plain words (top right) decides how the constructs of the standard are named: by what they mean (“exactly one of these”, “in this order”, “each item”, “text”) or by their own terms (oneOf, sequence, items, string). It is on to begin with; turn it off if you would rather read the terms themselves. The choice is remembered, and it holds for the cards, the panel and the documentation alike.
Finding your way
- Type (part of) a name or title in the search field (Ctrl+F or Ctrl+K) and pick a node from the list, or press Enter to step through the matches (Shift+Enter goes back): the way to it is opened up and it is centred.
- Or say what to change: type a command in plain words in the same field —
make amount optional,make amount required,rename amount to total,remove note,add note to order,make amount a whole number(or anumber,text,yes or no),note at most 35 characters,amount at least 1— with the names your schema uses. The field offers the command above where the matches stood; Enter carries it out, or, where the name stands in more than one place, you pick the place from the list. It is the same edit the diagram makes, so Ctrl+Z takes it back, and a command the schema cannot take says why. In Dutch the commands are Dutch:maak bedrag optioneel,hernoem bedrag naar totaal,notitie maximaal 35 tekens. - Grid, the tab beside Diagram, shows the same schema as nested tables, one row for each card, and what is open in the one is open in the other. The name, the type, how often and the description are edited in the row itself; a row is selected as a card is, so the details stand beside it, and a right-click or the ⋮ button offers what a card offers.
- A sample beneath the grid: where a file is paired with the schema — a record file, or a document of a set — its lines stand under the grid, each cut at its fields. Choose a value there and the grid opens at its field; choose a row and its value is marked in the sample. A line no part of the schema reads is marked in red, and the column In the sample says what each field holds in it. It is the sample the Ruler reads, and follows every change.
- Codes: where a field may hold only certain codes — a list of the schema, a table of a record schema or a set — the column Codes names its list, by its title or by its first codes, and hovering over it shows every code with what it means. Select the field and Node details lists its codes too, each with its meaning in your language.
- A layer over a large set is worked on in part: in its Grid you choose the working set as tiles; in its Diagram as cards of the set itself — the set, its messages and its library, a group where a level holds many — choosing a card and saying Work on this. Open reads only what you chose.
- A set whose documents are JSON (
"written": "json") shows the same table without positions or columns: a message holds fields of its own beside the parts of the library it names, + field in Patient adds one, and how often a field stands — once, at most once, at least once, any number — says whether it must be there. A layer over it narrows its fields as over any set. - A part’s variants: a part read one of several ways — by the codes a field of it holds — shows each variant as a row of its own, its codes beside it and its fields beneath. + variant of line makes one: its name and codes, and for a part’s first, which of its own fields chooses (that field is marked chooses the variant). A variant is renamed in its cell; its fields are added, lengthened and taken out as a part’s own, after them. Select a variant for its codes, the field that chooses and Remove the variant in Node details; a code of another variant is refused.
- A set’s code lists: in a set’s Grid, Code lists beside Table shows each list in a grid of its own — found by name, title or code, its codes made, renamed, taken out or pasted from Excel, its meanings in each language, and the fields that hold to it. + New version keeps the list as it stands, in the set itself, under the version it is, and the list goes on under the new one (proposed by counting on, dated today). Once a list has earlier versions, Since says from which version each code stands, a code taken out stays in the list struck through, and Compare with sets the list against an earlier version: each code added (+), taken out (−) or meant otherwise (~).
- Expand all and Collapse all (top right of the diagram) open everything, or close everything but the start point. A level with more than 25 cards is bundled: its cards hang behind dashed bundle cards — by the beginning of their names (
ADT), by first letter, or in runs of 20 in order (PID.1 … PID.20) where the order counts or all begin alike. Open a bundle as any card; a node you choose or find opens the bundle it is in. Whenever you close or open a branch, the card you did it on comes to the middle of the canvas, at the zoom you chose. - A card that groups others — exactly one of these, one or more of these, all of these, in this order, a condition — is open of itself, and closes and opens with its button like any other card. Expand all opens it again.
- Scroll or pinch to zoom, drag the background to move. Expanding keeps the zoom level.
- A diagram you open is centred on the canvas: a schema larger than the window is zoomed out until it fits, a smaller one is left at its own size rather than blown up. One too large to be read whole is zoomed out no further than its cards can be read, and shown from its start point — you move it from there; the fit button does the same. Choosing another start point centres it again.
- Once you have zoomed or moved a diagram, it comes back exactly where you left it — switching to the text and back, or to another document and back, keeps your view. Only a document that is new, opened afresh, or shown from another start point is centred again.
- Which cards are open is remembered per document.
Editing in the diagram
Node details
Click a card to select it; its details appear on the right. At the top: name, types, whether it is required, its occurrence and its reference. Below them are tabs:
- Facets — restrictions such as minimum, maximum, lengths and pattern (Add restriction…).
- Enumeration — the allowed values, one per row.
- Examples — example values.
- Documentation — title, description and comment (for XSD:
xs:documentation). - Other — for example the default value, read-only, write-only and deprecated.
- Generator — only while a generator profile is active: how example data is generated for this node.
Text values are typed as they are; other values as JSON (for example 42, true or "text").
Every option, and what it does
The whole list is here, and each entry is the same sentence the (?) beside that field shows — so whatever you meet in the panel you can look up here, and the other way about. Where the standards call the same thing by different names, both are given.
The node itself
| Name | What the thing is called: the property name in JSON Schema, the element or attribute name in XML Schema. It is part of the path that names this node, so renaming it rewrites every reference to it in the workspace. |
|---|---|
| Types | What kind of value may stand here - text, a number, a whole number, a truth, a list, an object, nothing. More than one is allowed and means any of them; in XML Schema this is the type the element or attribute is declared with. |
| Required | Whether the property has to be there. In JSON Schema the parent lists it under required; in XML Schema an element says so with minOccurs and an attribute with use=“required”. |
| Minimum occurrences | How few times this may appear where it stands. Nought means it may be left out altogether, which is XML Schema’s way of saying optional. |
| Maximum occurrences | How many times this may appear. Unbounded means no limit, which is maxOccurs=“unbounded” in XML Schema and an array without maxItems in JSON Schema. |
| Reference | Which named definition this node stands for instead of describing itself: a $ref in JSON Schema, a type or ref in XML Schema. The diagram follows it, into another document of the workspace if that is where it lives. |
| Default value | The value that stands where the document writes none. It is a statement about the data, not a rule: a document leaving the value out is still valid, and nothing fills it in for you. |
Numbers
| Minimum | The smallest the number may be, itself included (minimum, or XML Schema’s minInclusive). |
|---|---|
| Maximum | The largest the number may be, itself included (maximum, or XML Schema’s maxInclusive). |
| More than | A bound the value must stay above without reaching it (exclusiveMinimum, XML Schema’s minExclusive). In draft-04 this was a truth beside minimum; from draft-06 it is the number itself, and converting between drafts moves it for you. |
| Less than | A bound the value must stay below without reaching it (exclusiveMaximum, XML Schema’s maxExclusive). |
| Multiple of | The step the value must be a whole multiple of: 0.01 for an amount in cents, 5 for a count in fives. A multiple of a tenth, a hundredth and so on is how both standards say “this many decimals” (XML Schema writes that as fractionDigits), and the check is done in exact decimals rather than in floating point. |
| Total digits | The most digits a number may have in all, before and after the point: 5 allows 123.45 and not 1234.56. Leading and trailing zeros do not count. XML Schema’s totalDigits; JSON Schema has no word for it. |
| Fraction digits | The most digits a number may have after the point: 2 for an amount in cents. XML Schema’s fractionDigits; written as JSON Schema it becomes a multipleOf of 0.01. |
Text and values
| Minimum length | The fewest characters the text may have. Characters, not bytes: one letter is one, whatever it takes to write. |
|---|---|
| Maximum length | The most characters the text may have. |
| Pattern | A regular expression the whole text must match. A JSON Schema pattern is read as ECMA-262 in unicode mode and an xs:pattern in XML Schema’s own flavour, which is neither ECMAScript nor PCRE - so the same expression can mean two things, and each is checked by the rules of the schema it stands in. A pattern whose backtracking could be made to explode is refused rather than run. |
| Format | A named shape the text is written in: a date, a time, an e-mail address, a URI, a UUID. In JSON Schema format is an annotation the standard lets a reader ignore; here it is checked, and the generator writes values that fit it. |
| Allowed values | The whole list of values that may stand here, and nothing else (enum, XML Schema’s xs:enumeration). |
| Fixed value | The one value that may stand here (const, XML Schema’s fixed): a list of allowed values with a single member, said in one word. |
Lists
| Minimum items | The fewest items the list may hold. |
|---|---|
| Maximum items | The most items the list may hold. |
| No two the same | Whether the items of the list must all differ. They are compared as values - 1 and 1.0 are one number - and not as the text that was written. |
| At least this many matching | How many items must match the “contains” schema. Without it, one matching item is enough; with it, the count is the rule (2019-09 and later). |
| At most this many matching | How many items may match the “contains” schema (2019-09 and later). |
Objects
| Minimum properties | The fewest properties the object may carry, whichever they are. |
|---|---|
| Maximum properties | The most properties the object may carry. |
Words for people
| Title | A short name for people, not for programs: it is what the card shows and what the generated documentation puts at the head of an entry. |
|---|---|
| Description | What this is, in your own words. Where a node has one it becomes the label on its card, with the name beside it, and it leads the node’s entry in the documentation. In XML Schema it is written as xs:documentation inside an xs:annotation. |
| Comment | A note for whoever maintains the schema ($comment). It is kept with the schema and left out of the generated documentation, which is the difference between it and a description. |
| Examples | Values that would be right here. They are shown to a reader, and the generator writes one of them where you ask for realistic data from examples rather than from the constraints. |
| Read-only | Says the value is set elsewhere and a writer should not send it (readOnly). Nothing refuses a document for it; it is a statement about where the data comes from. |
| Write-only | Says the value may be sent but is never read back - a password being the usual case (writeOnly). |
| Deprecated | Says this is on its way out and should not be used in new documents (deprecated). It stays valid: a schema that refused it would break every document that still carries it. |
Renaming
Click the name of the selected card — or press F2 — to edit the name on the card, as in XMLSpy. Enter or clicking elsewhere keeps the new name, Escape keeps the old one. This works for properties, elements, attributes, definitions and named members. Rename… in the card’s own menu asks for the name in a dialog instead.
A name is rarely written in one place. Everything that points at what you rename is renamed with it — every reference to a named type, element, attribute, group or $defs entry, including the ones in *other documents of the workspace*. So before anything changes you are shown where the rename lands: a list per document, each place as that document writes it and the line it stands on. Rename everywhere carries it out; Cancel leaves your schemas exactly as they were. A name nothing points at has nothing to weigh up, and is simply renamed.
The rename is one step in this document, so Ctrl+Z takes it back here. The other documents are rewritten and stay rewritten; their tabs show as unsaved, so you can see what changed before you download them.
Making a named type
A type written inside one declaration can only ever be used there, and has no name to call it by. Make named type… in a card’s menu takes it out: the schema gains a named definition and the card keeps a reference to it. The name is suggested from the declaration it came out of — Policy becomes PolicyType — and you can change it before you confirm; a name the schema already uses is refused rather than quietly turned into another.
What that comes to follows the format. In an XSD the element stays exactly where it is, keeping its name, how often it may occur, whether it may be nil and what it says about itself, and gains a type= pointing at the new definition — an inline xs:complexType becomes a named complexType and an inline xs:simpleType a named simpleType, and a declaration that only named a built-in type becomes a named restriction of it. In a JSON schema there is no such split: the whole subschema moves to $defs and a $ref is left in its place.
It is worth doing even where nothing else points at the type yet. A named type can be used from anywhere — including from another document of the workspace — but it also turns up in the outline, can be started from, is offered while you type in the text editor, and gives whoever reads the schema a word for what the shape is.
Adding and removing
Right-click a card for its actions: Add property, Add … definition, Add … member, Add items schema, Add tuple item, Rename…, Remove, Start diagram here and Open referenced definition. Editing a referenced definition changes it everywhere it is used.
Delete — or Backspace, the key a Mac keyboard offers for it — removes the selected card with that same Remove. It is the menu entry, not a second way in: where the menu offers no Remove the key does nothing, so the document root, a card from another document and a locked card stay as they are. One press is one step, which Ctrl+Z takes back.
Copying, cutting and pasting
Ctrl+C copies the selected node — or the whole selection, where several nodes are selected — Ctrl+X cuts it, Ctrl+V pastes under the one card you clicked last. What goes on the clipboard is the schema text itself — the piece as your document writes it — so you can paste it into any editor, a message or another tool, and paste text from there back in here. A JSON Schema piece is the schema object, which carries no name: the place you paste it names it, and a name already taken gets a number. An XSD piece is the declaration, which carries its own name and the namespaces it needs to stand alone. Several nodes are those pieces one after another with a blank line between them; pasted back in here they are the pieces they were, in one step. Text that is no node of this schema is refused rather than guessed at, and a cut only takes the nodes out once the copy has been made.
Dragging a node somewhere else
Drag a card onto another to move the node there; dragging a card that is part of a selection drags the whole selection. The places it may land are marked while you drag and the rest are faded, because the engine is asked where it may go before the drop rather than refusing after it — so a drag either lands or does nothing. Several nodes may land where every one of them may, and nowhere else. What may land where follows the format: in a schema whose objects hold named properties a node becomes a property, or a member where you drop it on a composition; in XSD an element becomes part of the content model and an attribute joins the attributes, never the other way about. A node cannot be dropped into itself, into anything hanging below it, or onto the parent it already hangs from. It keeps its name, and a name already taken there gets a number. Locked cards neither drag nor take a drop.
Several nodes at once
Ctrl/Cmd + click adds a card to the selection and clicking it again takes it out. Shift + click extends the selection: every card of the layer from the one you clicked last to this one. Shift and a drag on empty canvas draws a rubber band and selects what it catches — plain dragging keeps panning the canvas. Draw the band up to the edge of the canvas and the canvas moves along, so the band can reach cards that were out of sight. Escape clears the selection.
Copy a path. Right-click a card in the diagram, a row in the grid or a place in the text and choose Copy path for a query (or press Ctrl+Alt+C on the selected card): the path the data that node describes has in a document goes on the clipboard, ready for the Query panel and a pipeline — a JSONPath for JSON and YAML ($.order.lines[*].sku), an XPath for XML and record files (/order/line/@qty, a name in a namespace written Q{urn:…}line). A card drawn from another schema, read-only here, has its path too, through the reference that brings it. Copy place in the schema (#/…), for a JSON Schema, copies where the node is written in the schema itself — a JSON Pointer as a $ref writes it (#/$defs/address, channelType.json#/properties/print), for a reference rather than a query. In a data document a right-click on a row, a card or a place in the text copies that piece’s path ($.order.lines[0].sku, /record0010[2]/amount). On the command line, schemantix path <document> --at <line>:<column> says the same.
Everything you can do to one card you can do to such a block: Ctrl+C, Ctrl+X, Ctrl+V, a drag, and Delete. For nodes of one layer a bar also appears to make them Required or Optional, Remove them, Group as one of, any of, all of or sequence, or require that One of these must be present — and right-clicking a card of the selection offers the same actions as a menu where your pointer already is, with the number of cards above them. (Right-clicking any other card is about that card, as always, and leaves the selection alone.) Each of these is one step, so one Ctrl+Z takes the whole block back — and where the whole of it cannot be done, none of it is: you will not find three of five nodes moved.
A block is cards of one layer: properties of one object, or members of one composition. That is what makes it a block at all — it has one place it came from, so there is one place it can go. Cards with no parent in common, a card together with something inside it, or cards from two different definitions are refused, and the bar says so, because each would ask for the impossible: a paste has one place to put what it holds, and moving a card together with something inside it would move the same schema twice. A single card is a block of one, wherever it sits.
After a block has moved, been cut or been pasted, the selection is let go: the cards are not where they were, so the paths that named them no longer do. Where the block landed is opened up for you instead.
Undo
Undo and Redo in the toolbar (Ctrl+Z, Ctrl+Y or Ctrl+Shift+Z) take back diagram edits — even on locked nodes. The history starts again after the text has been edited. In a field — the search field or the node details — these keys undo and redo your typing there instead.
Cards from another document of the workspace are read-only here; double-click one to edit it in its own document.
Switching between text and diagram
Text and diagram are two views of one document. They are synchronized when you switch views with the Text and Diagram tabs, not while you type:
- Switching to the diagram reads and validates the text. If the text has syntax errors the diagram is not available until they are fixed: the status bar says so, and Problems says where.
- Switching to the text writes it anew from the diagram, with the tool’s own formatting. Comments and descriptions are kept.
- You keep your place: in the text the cursor goes to the node selected in the diagram, and in the diagram the node under the text cursor is selected, opened up and centred.
- The view you leave a document on is the view you find it on again — coming back to its tab, and opening Schemantix again later. Coming back is not a switch you made, so it never asks you which version a document is: one whose text does not parse, or whose version is not settled yet, waits on its text (checked all the same, so its problems are listed) until you ask for its diagram.
Problems, errors and locking
The Problems panel lists the errors and warnings of the active document with their line and column. Folded, it is one bar with the number of problems on its tab, and a problem that arrives opens it. Click a problem to go to it: in the text to its place, in the diagram to its node; in the diagram, Show in text goes to its place in the text. For a data document, Show in schema opens the part of the schema a problem comes from. Some problems offer a one-click fix, for example renaming definitions to $defs together with every reference to it, splitting dependencies into dependentRequired and dependentSchemas, or Load for a web document. A keyword another version spells differently keeps working and is saved exactly as you wrote it — those fixes are an offer, never something that happens behind your back. Revalidate (in the text and for data documents) checks again at once; in the diagram the list is always current.
What no document can satisfy
A schema can read without a fault and still describe documents no one can write. In JSON Schema, OpenAPI and AsyncAPI the check warns of: an example or default that breaks the constraints beside it (examples/0: the text is shorter than 8 characters); a name that is required but that a closed object — additionalProperties: false — cannot have, with the property that was probably meant (“Did you mean addresLines?”); a branch of an *exactly one of* or *one or more of* that never holds for that reason; and a pattern beside a format that no value seems to meet together, such as DD-MM-YYYY beside date (which is YYYY-MM-DD). The generator steps around the first three where it can, and says so.
When the diagram is locked
- Whether the errors came from the text or from a diagram edit, the nodes they affect (red) are locked and the rest of the diagram stays editable. The status bar says Errors (from text) — affected nodes locked or Errors (from diagram) — affected nodes locked.
- If another document of the workspace changed and gave this one errors, the whole diagram is read-only: the edit that caused them was made elsewhere. The status bar says Errors (from another document) — diagram locked.
- The text editor is never locked, and neither is its right-click menu — those changes are how an error gets fixed. Rename… and Make named type… are offered on a node standing in an error just as on any other.
- A node locked only because its own name is wrong can still be renamed — in the ruler’s Name field, or with the rename Problems offers (“Rename it to …”) — since that is the way out of the error. Nothing else about it can be changed until the name is right.
The text is never locked. Navigating the diagram — expanding, collapsing, selecting, searching — is always possible.
Versions
Every document is validated strictly against its own version, and keywords or constructs of another version are reported. The version comes from the document: $schema for JSON Schema, vc:minVersion for XSD, openapi for OpenAPI.
- Supported are JSON Schema draft-04, draft-06, draft-07, 2019-09 and 2020-12, XSD 1.0 and 1.1, and OpenAPI 3.0, 3.1 and 3.2. A schema with
"$schema": "https://json-schema.org/draft/2019-09/schema"opens as 2019-09, with its own keywords such as$recursiveRefanddependentRequired. - draft-06 is read as itself and not as its neighbours:
$ididentifies (draft-04 writesid),exclusiveMinimumandexclusiveMaximumare numbers rather than booleans,trueandfalseare whole schemas,const,contains,propertyNamesandexamplesare its keywords,requiredmay be empty and1.0is an integer — whileif/then/else,$comment,readOnly/writeOnlyandcontentMediaType/contentEncodingare draft-07’s and are reported in a draft-06 document as keywords of another version. - If the version cannot be determined — no
$schema, or one the tool does not know — you are asked to confirm one, with the nearest supported version suggested. Nothing is guessed silently. You are asked when you switch to the diagram or press Revalidate, never while you type or when a document comes back the way you left it; one answer holds — for the schema’s tab, its place in the workspace, the documents paired with it, other windows and the next session — until the text says a version itself. Until it is answered the schema is not read at all, so it shows no diagram and the documents paired with it are not checked against it, which their Problems say. - Schema › Other version (download or convert)… converts the document to another version, or downloads a converted copy and leaves the document as it is. Constructs that have an exact equivalent are rewritten (for example tuples,
const,definitions/$defsanddependencies/dependentRequired/dependentSchemas); anything the target version cannot express is kept and reported. - An XML Schema can also be converted to JSON Schema: pick a JSON Schema version under Other version…. Open converted copy opens it as a new document next to the XSD (Download saves it). Elements become properties (repeating ones lists, required ones required), attributes properties
@name, a value next to attributes#text, a choice aoneOf; types become definitions, built-in typesstring/integer/number/booleanwith their format and bounds, facets the matching keywords (fractionDigitsamultipleOf,0.01for two). What JSON Schema cannot express — keys, assertions, namespaces, XSD-only patterns, the number of digits in all (totalDigits) — is named in the status bar. - A JSON Schema converts to XML Schema the same way: pick an XML Schema version. Properties become child elements in a sequence (required ones must occur; an array property a repeated element, other lists
itemelements),@nameproperties attributes and#textthe text next to them. Definitions become named types; the first$refin anallOfis the base a type extends; aoneOfofrequirednames becomes a choice, of values a union;nullnext to another type makes an element nillable. Types become built-in types (a date, time, duration or URIformatgivesxs:date, …); bounds, lengths, enumerations andconstbecome facets, amultipleOfof a power of tenfractionDigits, patterns anchored XSD patterns. The document element isroot, or named after the definition the schema refers to, or one per property when the schema allows exactly one of them — as a converted XSD does, so a schema converted there and back keeps its shape. The content of elements is closed: what XML Schema cannot express — other properties, conditions, tuples and unique items, names that are not XML names (they are renamed),nullas a value — is named in the status bar. - Rules beside an XSD 1.0. XSD 1.0 has no
xs:assert, so a schema whose rules have to go with it — a set, a record schema, an XSD 1.1 — written as XML Schema 1.0 has them written beside it as a Schematron of the same name (invoices.xsdandinvoices.sch): Open converted copy opens both, Download saves the two together as a zip. Each rule stands at the element it is about — a record's rules at that record, a rule of the whole file at the document element — and its message in Dutch goes with it. Written as XML Schema 1.1, the rules stay in the XSD.
XML Schema (XSD)
- The start points are the global elements and types.
- Elements of a sequence, choice or all group show their occurrence; attributes are shown as properties.
- Built-in types such as
xs:dateare shown as values; named types, element references, groups and attribute groups are followed when you expand them. - Declarations the diagram does not show — imports, identity constraints, assertions, extra facets, annotations of other tools — are kept and written back unchanged.
- A document that uses XSD 1.1 constructs without declaring its version asks you to confirm one.
- A schema may be written for both versions at once and say so on the pieces themselves:
vc:minVersionandvc:maxVersionname the versions a piece is for, andvc:typeAvailable,vc:facetAvailableand their negatives name what a processor must (or must not) know for it to apply. A piece that is not for the version the document is read at is simply not there — not flagged — which is the point: the same file is then a schema under either version, and the two spellings of an element never collide.vc:maxVersion="1.1"means “up to but not including 1.1”. - A `default` or a `fixed` must name a value its own type has.
<xs:element name="n" type="xs:decimal" default="XII"/>promises a value no document could ever hold, and no document would ever show it: a default is used exactly where the element or attribute is left out, so the value it names is never supplied and never complained about. It is said here instead, with the value and the reason, and the whole type is asked — the built-in it rests on, its patterns, its allowed values and its bounds, the item type of a list and the members of a union. A type whose content is a sequence of elements has no value to constrain at all, and adefaultorfixedon it is reported the same way. In XSD 1.0 a type that is or is derived fromxs:IDmay carry no default or fixed value at all, since every identifier in a document must be its own; XSD 1.1 allows it, and the same file is judged by the version it is read at. - A document may declare its own entities, between the square brackets of its
<!DOCTYPE>, and they are put in place. It may also put its declarations in another file —<!DOCTYPE d SYSTEM "d.dtd">, or<!ENTITY e SYSTEM "e.ent">— and that file is not read. What the editor never does is go and get it: not off your disk, not off the network, and not out of the workspace either, so an entity declared out there — or one whose declaration may be out there, the document naming such a file — stands for nothing, the document is read all the same, and the reference is listed under Problems as a warning, by name. Nothing is fetched. An unparsed entity — one declaredNDATA— is named back to you as the document declared it, which is not the same as reading it: the file it points at is never opened, and a reference to one is an error wherever it stands. Text that an entity does expand to is counted against a 8388608-byte limit, so a document cannot be made to unpack into more text than that. - A DTD also says what its attributes are, and that is read too. The
ID,IDREFandIDREFStypes it declares are what tellfn:idandfn:idrefwhich attributes are identifiers — an attribute calledidis not one, and an attribute of typeIDis one whatever it is called — and anxml:idis an identifier wherever it stands, declared or not. A default value it declares (#FIXED "x", or a bare"x") is supplied where the document leaves the attribute out, which is what XML asks of every reader and not only of a validating one; anxmlns:pdeclared that way binds the prefix like any other declaration would. What is still left unread whole rather than half read is a DTD that builds its declarations out of parameter entities (<!ATTLIST e %atts;>). - A prefix has to be declared where it is used.
<tns:element/>needs anxmlns:tnson that element or on one above it —xmlandxmlnsare the only two prefixes XML declares for you. A document that uses an undeclared prefix is not read at all: it says nothing about which namespace the name belongs to, and reading it as a name in no namespace would be reading a different document than the one on screen. The message names the prefix and the name it stands in. - An element that may stand in for another takes a type derived from that other’s. A
substitutionGroupsays a document may write this element wherever the element it names may stand, so its type has to be one the head’s type covers: a restriction of it, an extension of it, or — where the head’s type is a union — one of the types that union joins. A list and a union are derived fromxs:anySimpleTypeand from nothing narrower, so a head typedxs:anySimpleTypetakes any simple type at all while a head typedxs:stringdoes not take a list of strings. An element that gives no type of its own simply takes its head’s, and can never be wrong about it. Nothing in a document could ever show this, which is why it is said about the schema: every document that writes the element is checked against that element’s own type. - A reference matches the name written in it, not the name `form` would make of it.
<xs:element ref="foo"/>points at a *global* declaration, so the name your document has to write is the one therefspells out: the namespace its prefix is bound to, or no namespace at all for a barefooin a schema that declares no default namespace.elementFormDefault,attributeFormDefaultandformsettle the namespace of local declarations — the ones written with anameinside a type — and have nothing to say about a reference. That holds even when the document carrying the global declaration is not open: your document is still matched against the name the reference writes, and only what that declaration *says* about the element goes unchecked. - XML documents can be checked against an XSD — keys,
xsi:typeand substitution groups included — and get suggestions from it while you type; see “Data documents”. An XSD can also be converted to JSON Schema, and a JSON Schema to an XSD; see “Versions”.
Schematron
ISO Schematron (ISO/IEC 19757-3) states rules about an XML document in XPath, each with what it says where it does not hold: “the total is the sum of the lines”, “a Dutch address has a postcode of four digits and two letters”. An XSD says what a document looks like; a Schematron says what must be true of what is in it. Peppol and UBL, HL7 CDA and many Dutch government standards use the two together.
Writing one
File › New… › Schema › Schematron makes one with a pattern, a rule and an assertion to change. A .sch file you open is recognised by its sch:schema. The text editor completes its elements and attributes, and the Problems panel says what is wrong before any document is asked: an expression that is no XPath, a variable defined twice in one scope or defined nowhere, an extends naming no abstract rule, an is-a, active or defaultPhase naming nothing, an unknown diagnostic or property, an unknown query language.
Its diagram shows its patterns and their rules; each rule’s card lists its assertions, asserts … for an assert and reports … for a report. An xs:assert of an XSD and a record type’s test are shown the same way.
Checking a document against it
Open the XML document, and choose the Schematron in the Schematron box of its data bar, beside the Schema box. A Schematron is never offered as the schema: it says nothing of a document’s shape. The document is then checked against both every time, and what the Schematron finds is in the Problems panel beside what the schema finds: an assert that does not hold, and a report that does, each on the node it is about and in the words its author wrote. A role of warning or info makes it a warning. A Schematron that cannot be run says so, with what is wrong with it.
What the Schematron includes (sch:include, sch:extends href) and the documents a pattern asks of (documents) are read from the workspace. Abstract patterns and rules, phases, variables, diagnostics and properties are all read, and so are xsl:key and xsl:function at its top, which the XSLT query languages allow.
On the command line: schemantix validate order.xml --schema order.xsd --schematron rules.sch. --phase chooses the phase, and --svrl report.xml writes the report the Schematron made, in SVRL, the standard’s own report format. Without --schema the document is checked against the Schematron alone.
QuickFixes
A Schematron may say how a failed assertion is mended, in the Schematron QuickFix language (sqf:fix beside its rules, named in an assertion’s sqf:fix). Its fixes are offered on the finding in the Problems panel — Fix: …, its description as the button’s tooltip — only those whose use-when holds there. A fix that asks a value (sqf:user-entry) asks it first, beside the button, starting at its default. Applied, a fix is an edit of the document like any other: it is checked again at once, and Ctrl+Z undoes it. All four activities are carried out — adding a node before, after or in another, deleting, replacing, and replacing within a text — and a fix may call another. What stands before the document element and after it is kept as written; the element itself is written again as the engine writes it (quotes, empty elements).
On the command line, schemantix validate order.xml --schematron rules.sch --fix applies each QuickFix that asks no value — the one an assertion names as its sqf:default-fix, or the one it is offered — says each, and writes the file once; a fix that asks a value, or a finding offered several with no default, is said and left for the editor.
Documents that break each rule
In the example-data editor of an XSD, choose a Schematron of the workspace beside A document per rule that breaks it. The generator makes documents valid against the XSD — as many as the editor asks for, and one on every bound it sets — and asks the Schematron of each. For each rule you get the document that breaks it and as few other rules as there are, in a zip with a list of which file breaks which rule. A rule none of them breaks is said to be one: a document that breaks a free XPath test cannot be worked out, so write that one by hand, or ask for more documents. On the command line: schemantix generate order.xsd --schematron rules.sch --out folder.
Which edition: a Schematron that says nothing in schematronEdition is read as the newest edition, 2025, which holds everything of the older ones. 2025 brings groups (sch:group, where every rule that matches fires), a top-level sch:rules of abstract rules, libraries (sch:library, taken in with a top-level sch:extends), schema parameters, typed variables (as), a phase’s from and when (with the phase #ANY), a rule’s visit-each, an assertion’s severity, and a flag, role or severity written as $name or with expressions in braces. The 2020 and 2025 editions are read as the SchXslt2 implementation reads them, as their text is not freely available. A Schematron that names the 2016 or 2020 edition and uses something of 2025 is told so.
RELAX NG
A .rng in RELAX NG’s XML syntax is a schema like an XSD: the diagram draws each element with its attributes and its content — a group as a sequence, a choice, an interleave — and optional, zeroOrMore and oneOrMore as how often what they hold occurs. A define is a definition and a ref a reference to it; each element a start can be is where a document starts. A data or value of the XML Schema datatypes is a value with its parameters as bounds. What the diagram has no card for — a name class of more than one name, externalRef, include, list, a nested grammar — is kept as written, and the schema is written back as RELAX NG after an edit.
Problems says what makes a schema incorrect, as the RELAX NG specification does: an element or attribute where none may stand, a reference to no definition, two definitions of one name that do not say how they combine, an unknown datatype or parameter, a value that is no value of its type, and the restrictions of its section 7 — an attribute in an attribute, an element in a list, values mixed with elements, attributes that could stand twice, an interleave whose two sides hold the same element.
Documents are checked against it as they are against an XSD: open the XML beside the schema, and every fault is said where it is — an element that may not stand there, an attribute not allowed or missing, a value of the wrong kind, content that ends too soon. An include or externalRef finds the schemas you have opened; one naming a document you have not opened is said in Problems, with a quick fix to name another. Example data is made in the namespaces the schema names. Schema › Other version (download or convert)… converts a RELAX NG schema to XSD and an XSD to RELAX NG; what the other cannot say is listed in the status bar. James Clark’s test suite passes whole.
The text editor colours a .rnc as the compact syntax: keywords, names, literals and ## documentation apart. Lay out is not offered for it, since it lays out only JSON and XML.
WSDL
A .wsdl describes a SOAP web service: the XML Schema types of its messages, the operations of each port type with what they receive and answer, the binding of those to SOAP, and the address a service is offered at. Its types are drawn, edited and checked as an XSD’s are, and written back into the description after an edit. Where its types hold more than one schema, each is drawn, edited and checked too: a reference into another of them opens its definition in the same diagram, and an edit of one is written back into its own xs:schema. A schema with a component whose kind and name another schema of the types has too is kept as written, and found by its namespace, as an imported schema is. Types kept in an XSD of their own, as most descriptions keep them, are read from beside the description: a schema of the types that imports or includes one by its schemaLocation brings in its elements and types, and what it includes in turn. Open the folder that holds them; a schema not found is said where its schemaLocation is written.
Problems says what makes a description wrong: a part naming an element or type the types do not have, an operation naming no message, a binding of a port type that is not there, a port of a binding that is not there, two components of one name, a part that names both an element and a type.
The operations stand beside the diagram, each by its port type and its name, opening on what it receives, answers and may fail with — each the element of the types it is. A payload, opened beside the description, is checked against the element it starts at; schemantix operations lists the same.
Each input, output and fault is a place a document starts: example data made from one is the SOAP envelope it travels in, its payload in the Body (a fault in a Fault’s detail), and an envelope opened beside the description is checked by the payload it carries. Schema › Other version (download or convert)… converts a description to OpenAPI — each operation a POST /service/operation, its input the request body, its output the 200 response, its faults the 500 response — and an OpenAPI document to WSDL the other way; what the other cannot say is listed in the status bar.
AsyncAPI
An AsyncAPI document — version 2.6, 3.0 or 3.1 — describes an event-driven interface: the channels an application uses, what it sends and receives on each, and the messages that travel there, with the JSON Schemas of their payloads and headers. It may be written in JSON or in YAML, and is one by its mark: asyncapi: at its top, or a name ending in .asyncapi.yaml or .asyncapi.json. Its version is the first two numbers of what asyncapi says (3.0.0 is 3.0); a document that says another version, such as 2.4.0 or 3.2.0, is asked about, never guessed. 3.1 is 3.0 with one more protocol, ROS 2.
Its schemas are checked, completed and drawn as a JSON Schema draft-07’s are. Each schema under components/schemas is a definition of its own name, and a $ref: "#/components/schemas/Order" goes to it. Every other schema — a message’s payload and headers, a trait’s headers, in 2.6 a channel parameter’s — is a message, named by where it stands (/channels/orders/messages/OrderPlaced/payload) and called what a reader calls it: channel orders · payload of OrderPlaced. A schema written in another format — Avro, Protobuf, RAML, OpenAPI’s — is kept as it is and said not to be read; it is not checked, drawn or used to judge a payload. The rest of the document is edited in the text: an edit in the diagram writes the text again with it exactly as it was.
Problems says what makes a document wrong: a required field left out (info, its title and version, an operation’s action and channel, a server’s host and protocol), an action other than send or receive, a $ref naming nothing, an operation naming a message its channel does not have, a channel parameter its address does not use (or one it uses and does not hold), two operations or messages of one id in 2.6, a server a 2.6 channel names and the document has not got — and an example of a message that does not fit it.
A document converts between 2.6, 3.0 and 3.1, and to and from OpenAPI (Convert to another version, or schemantix convert --to asyncapi@2.6 and --to openapi@3.1): an operation it receives becomes an operation at its channel’s address, one it sends a webhook, and what the other side has no place for is said.
A document is also judged by the AsyncAPI Initiative’s own schema of its version: a binding of the wrong shape for its protocol (a misspelt Kafka field, a ROS 2 binding without its node), a security scheme, an example with neither a payload nor headers — each said at the field that is wrong. A schema inside a binding is read too — a Kafka message’s key, an HTTP operation’s query, a WebSockets channel’s headers — as a message of its own (kafka key binding of OrderPlaced), so you can draw it, edit it and check a document against it. A message’s traits are merged into it: its headers are judged with its traits’ headers merged in, as the version says (in 2.6 a trait overrides the message, in 3.0 and 3.1 the message’s own field wins). A channel or a message kept in another file ($ref: ../common/messages.yaml#/commentLiked) is read from that file when it is open beside the document: its messages are listed with their operations and you can check a payload against them; a file that is not there is said, and so is a place it does not have.
GraphQL
A GraphQL schema — of the specification’s September 2025 edition, or of October 2021 where you choose that edition as its version — describes an API by its types: objects of fields, each field with its arguments and the type it answers with; the interfaces they implement, unions, enums, input objects and scalars; and the root types its queries, mutations and subscriptions begin at. It is written in GraphQL’s own schema language (SDL), and is one by its name — .graphql, .graphqls or .gql — or by beginning as one does (type Query {). The text editor colours it as GraphQL, and does not lay it out.
In the diagram each type is a definition: an object, an interface or an input object a card of its fields, each field a card of its type — a list as a list, a field written with ! as required — with its arguments beneath it; a union a choice of its members, an enum its values, and the interfaces an object implements an “all of” of them. A description is its documentation, @deprecated its deprecation and a default value its default; every other directive is kept as written. An edit in the diagram is written back as GraphQL with all of it, and so is each extend where it stood, every comment, the directive definitions, the schema definition, and what a schema has no place for (an operation, a second type of one name), kept as written.
Problems says what makes a schema wrong, by the specification’s own rules: a type named that is not defined; a name used twice, or beginning with __; a type of nothing; no query type; a field returning an input object, or an argument taking an object; an interface implemented without all its fields and arguments, or with a field of a type that does not stand for the interface’s; a union of something that is no object; an input object that holds itself through non-null fields only; an extend of a type there is not; a directive used where its definition does not allow it, twice, or with an argument wrong or left out; and a default value that is no value of its type. What only the working draft has — @oneOf, @deprecated on an argument — is warned of, and not read.
The diagram starts at the interface: the query, mutation and subscription types each a frame, each of their fields an operation, and under each its arguments and its result. A JSON document opened beside the schema is checked against what it starts at — a type, or an operation’s arguments or result — and a response ({"data": …}) against the query type: an Int must be a whole number of 32 bits, null stands nowhere a type is non-null, and an object holds only fields of its type. Example data is made from any of them. On the command line schemantix validate, generate, operations and diagram work as for OpenAPI, and --operation book picks an operation’s result. File › New offers a schema of one query field, or a small library to start from.
September 2025 reads what 2021 did not: @oneOf input objects (exactly one of their fields is given, and not null), @deprecated on an argument or an input field, and a \u{…} escape of any character. It also holds a schema to the new rules: a @oneOf object’s fields nullable and without a default, nothing required deprecated, a field deprecated only where the interface’s is, and default values that never lead back to themselves. Read as 2021, these are warnings instead.
A query in the schema document is a start of its own: write query Titles { all: books { name: title } } below the types and *Titles* can be chosen as where a JSON document starts. A response is then judged by what that query asks for — each field under its alias, fragments, __typename — and an example made of it is a response it could get.
Rename a type in the diagram and the schema definition (query: …) and the fragments (on …) follow.
CSV on the Web
A .csv-metadata.json — the W3C’s *CSV on the Web* metadata — says what the columns of a CSV are: their names and titles, their datatypes with formats and bounds, which may be empty, a table’s primary key and the tables its foreign keys refer to, and how the file is written (its delimiter, quotes, header). It opens as a schema: each table is drawn as a record type with its columns as fields, edited in the diagram, and written back into the metadata with everything else it says kept.
Problems says what is wrong with the metadata as the standard does: what makes it no metadata (no @context, a table with no url, two columns of one name, a virtual column before one that is not, bounds that cannot hold together) is an error, and a property with a value it may not have is set aside with a warning.
The W3C’s own validation tests pass whole: every one the working group approved.
A group of tables is checked across its files: a CSV is the table whose url names its file (or, where none does, the one whose titles its header gives), and its foreign keys into the other tables are judged against their files when those are open too. Change one table’s file and the others are checked again. Its grid, its tree and an example are its own table’s.
The W3C’s conversion tests pass whole too: all 270 to JSON and all 270 to RDF.
SQL DDL
A SQL DDL script — the CREATE TABLE statements of a database — is read as a schema of the rows of its tables. It is written in a dialect, and each dialect is a version: the SQL standard (SQL:2016), PostgreSQL, MySQL (and MariaDB), SQL Server, SQLite and Oracle. The dialect is told by how the script is written — backquoted names and AUTO_INCREMENT are MySQL’s, [brackets] and IDENTITY(1,1) SQL Server’s, SERIAL and :: PostgreSQL’s, AUTOINCREMENT SQLite’s, VARCHAR2 and a / on a line of its own Oracle’s — and a script that tells none is read as the standard. A script is one by its name, .sql or .ddl, or by beginning as one does (CREATE TABLE, SET, DROP). The text editor colours it as SQL, and does not lay it out.
In the diagram each table is a definition, a card of its columns. A column is a value of its type: a whole number of the bits its type has (SMALLINT, INT UNSIGNED), a number of its digits (NUMERIC(10,2)), text of its length (VARCHAR(255)), a truth, a date or a moment — or a value of an enum or a domain the script defines (PostgreSQL’s CREATE TYPE … AS ENUM, CREATE DOMAIN). A column is required where it is NOT NULL (or in the primary key) and nothing gives it a value of its own — no DEFAULT, no identity or SERIAL, no computed value. A CHECK of a simple shape — price > 0, status IN (…), n BETWEEN 1 AND 10, LENGTH(code) <= 4 — is a restriction of its column; any other is kept as an assertion of its column or its table. A foreign key of one column is drawn as a reference to the column it names. A COMMENT ON, MySQL’s COMMENT, SQL Server’s extended property MS_Description (EXEC sp_addextendedproperty) and, in SQLite, a comment at the end of a column’s line are the description. A table that inherits another (INHERITS), or is a partition of one (PARTITION OF), has its parent’s columns. An ALTER TABLE … ADD of a table of the script is folded into it, and so is PostgreSQL’s ALTER COLUMN … SET DEFAULT.
An edit in the diagram is written back as SQL in the dialect read: each statement where it stood, a type with the length or digits the model gives it, a NOT NULL, a DEFAULT or a CHECK made anew where the edit asks for one, a description as the dialect writes one — and every comment, every statement the format does not read (an index, a view, a grant, an insert, a procedure), kept as written. A procedure’s body is read whole, to its GO in SQL Server, to its / in Oracle, and to the delimiter a MySQL script sets with DELIMITER. Rename a table or a column and the script names it anew wherever it named it: its keys, the foreign keys of other tables, its checks, its ALTER TABLE and COMMENT ON, the tables that inherit it, its indexes. An inherited column edited in a child table is edited in the table that declares it, as PostgreSQL has it. The text editor completes the dialect’s statements and types, and the script’s tables after REFERENCES.
Problems says what makes a script wrong as a schema: a statement it cannot read (placed where it goes wrong); two tables, two columns or two primary keys of one name; a key, a check or a COMMENT ON naming a column the table has not; a foreign key naming a table neither this script nor another open one has (a table is found by the name after its CREATE TABLE, whatever its file is called, and the diagram follows the relation into the other script), a column of it that is not there, a table without a primary key where it names no columns, or another number of columns; a default that is no value of its column. It warns of a type the dialect does not have, of an ALTER TABLE of a table elsewhere, and of a statement that changes a table it does not follow (DROP COLUMN, CREATE TABLE … AS SELECT). What now? beside such a finding offers a change to the text: the nearest name that is there for one that is not, a table or column created, the reference taken away, a second name made distinct, a second primary key or a wrong default taken out.
A row is checked as a JSON (or YAML) object opened beside the script, against the table it starts at — the only one, where the script has one: every required column there, no column the table has not, null only where a column may be null, and each value one of its type, within the bounds, the length, the digits and the values its type and checks give it. Its checks of every shape are asked too — born < hired, code LIKE 'S-%', a domain’s VALUE % 2 = 0 — as the dialect evaluates them (MySQL compares text without case or accents, SQL Server without case). A regular expression is run in its database’s own dialect: PostgreSQL’s ~, ~*, !~, !~*, regexp_like and SIMILAR TO, MySQL’s REGEXP, RLIKE and REGEXP_LIKE (ICU’s, without case as its collation has it), Oracle’s and SQL Server’s REGEXP_LIKE, and the standard’s LIKE_REGEX; a pattern that is none of its dialect is marked in the script. Text is put in order as the collation has it: Oracle and SQLite by the characters’ numbers, MySQL and SQL Server without case; PostgreSQL’s default collation is the database’s, so where C and a language’s order disagree ('a' < 'B') the check is not run unless it, or its column, names one (COLLATE "C"). A check holding a CASE, a function this tool does not know, or a construct of a pattern it does not run (ICU’s \X) is said once as not run. A CSV or TSV file of rows is checked too, each row on its own line; a script of several tables checks it against the table the file is named after (book.csv). Example rows are made from any table. On the command line schemantix validate, generate, convert and diagram work as for the other formats, and --schema-version names a dialect (--schema-version mysql; schemantix new sql --version mysql). File › New offers a script of one table, or a small library to start from.
On the command line: schemantix convert shop.sql --to json-schema, or schemantix convert shop.xsd --to sql@postgresql.
Apache Avro
An Apache Avro schema — an .avsc file, a JSON document naming a type — is read as a schema of the values Avro writes. Avro 1.11 and 1.12 are its versions; 1.12 adds the logical types timestamp-nanos, local-timestamp-nanos and big-decimal, and a schema is read as 1.12 unless you choose otherwise. A file is one by its name, .avsc, or by being a JSON document whose type is record, enum, fixed, array, map or a primitive.
A protocol and Avro IDL: an .avpr is a protocol — its types, and its messages, each called with parameters, answering with a value and perhaps with errors — and an .avdl is either written in Avro’s own language, IDL (protocol Mail { record Message { string to; } string send(Message m) throws Failure; }, or a schema in the schema syntax, namespace shop; schema Order; record Order { … }). An IDL file is read into the very schema its JSON is, so everything below holds for it too, and what is wrong is placed in the IDL; a schema read from IDL is written back as IDL. A protocol’s messages are its operations: the operations panel and the interface overview list each one under the protocol, its request (the arguments), its response (the result) and each error (a fault), and a document is checked against any of them. Schema › Avro IDL (.avdl) and Avro JSON (.avsc, .avpr) save a schema as the other — IDL as JSON (.avsc, or .avpr for a protocol), JSON as IDL. Problems also says a one-way message that answers, an error that is no error, and IDL that does not read, where it goes wrong. An import of another file is not followed: what it defines is taken as given, said once as a warning.
In the diagram each named type is a definition under its full name (com.example.shop.Order): a record a card of its fields, an enum a list of its symbols, a fixed a string of its size. An array, a map and a union are drawn where they stand, a union as a choice of its branches. A field without a default is required; one with a default is not.
An edit in the diagram is written back as Avro: a named type where it was written, or at its first use; a field you make optional becomes a union with null that defaults to null; a type nothing refers to becomes a further branch of a union at the top.
Problems says what makes a schema wrong: a type that is no type, a named type without a name or with one a primitive has, two types or two fields of one name, an enum without symbols or with a symbol twice, a fixed without a size, an array without items, a map without values, a union inside a union or with one type twice, and a default that is no value of its field’s type (a union’s default is a value of its first branch). A logical type that does not fit its type, or that came after the version read, is a warning: a reader ignores it, as the specification says.
A JSON document is checked in Avro’s JSON encoding against the schema’s type, or the record you start at: a union’s value other than null is wrapped in an object naming its branch ({"string": "x"}), bytes and fixed are strings of their bytes, and a number must fit the bits of its type. Examples are made in the same encoding.
On the command line: schemantix validate order.avsc order.json, or schemantix convert person.json --to avro.
Protocol Buffers
A .proto file — proto2, proto3, or an edition (2023, 2024) — is read as a schema of the JSON its messages are written as in the canonical JSON mapping. The version is the file’s own word: syntax = "proto3";, edition = "2023";, and proto2 where it says neither.
In the diagram each message and enum is a definition under its full name (shop.Order.Line): a message a card of its fields, an enum a list of its values. A repeated field is a list, a map an object of its values, a oneof’s fields are marked as such. A well-known type — Timestamp, Duration, Struct, the wrappers — is the value the mapping makes it, with no file of its own. A service’s methods are its operations: the operations panel and the interface overview list each one under the service, its request and its response.
An edit in the diagram is written back as a .proto: each declaration in the order it was read, with its number, options, comments and what it reserves; a field the diagram adds is numbered after the highest, an enum value after the last.
Problems says what makes a file wrong: what does not read (placed); names twice; a type no declaration has; field numbers out of range, twice, or reserved; a label the version does not have, or a proto2 field without one; a group outside proto2; defaults and extension ranges in proto3; a map key of a type no key may be; two fields of one JSON name; an empty enum, an open one whose first value is not 0, two values of one number without allow_alias; a method that takes or answers no message. An import of another file is not followed (a well-known type’s is known without it): what it defines is taken as given, said once as a warning. The editions’ features are read where they bear on this — an enum closed, a field LEGACY_REQUIRED — from the field, the message and the file.
A JSON document is checked as the mapping writes one against a message: its fields by their JSON names or their own, at most one of a oneof, proto2’s required ones there; a 64-bit integer as a number or a string of its digits, bytes as base64, an enum by a value’s name or number, a Timestamp as RFC 3339, a Duration as seconds with an s. Examples are made of any message.
On the command line: schemantix validate order.json --schema shop.proto --start shop.Order, or schemantix operations shop.proto.
Dependency rules
A dependency rule ties fields together, where a schema on its own cannot: “when country is NL, then postcode matches [0-9]{4}[A-Z]{2}”, “amount is at most creditLimit”, “when status is cancelled, then cancellationDate is present”. You write one with a few clicks; it is kept in the schema in the schema’s own language, and every part of the editor reads it.
Writing one
Select the part the rule is about — an element, an object, a record type — and open the Rules tab of its details. Add a rule… opens a window with two halves. Under When, choose Only when… and say what must hold for the rule to apply, or choose Always for a rule that always applies. Under Then, say what must then hold. Each line is a field, a word and, where the word needs one, a value. Several fields at once: the words *exactly one of*, *at least one of*, *at most one of* and *all or none of* say how many of the field and the others you tick beside it must be there — “at least one of phone, email and fax is present”. + and adds a line: all lines of a half must hold. The sentence under the window says the rule back to you as it will be kept. A rule may have a name: type it in the field before the rule and leave the field to give it, empty the field to take it away. It is how a finding and a layer speak of the rule, and it is written where the format has room for one — an id, a SQL CONSTRAINT, a JSON Schema title. What a rule says where it does not hold: Message… beside a rule opens a window with its Weight — an error, a warning or a note; only an error makes a document fail its schema —, its Message, a message in each language the application speaks (a reader of that language is shown theirs, the message above where there is none), and an Acknowledgement code: the code a standard’s acknowledgement sends back where the rule does not hold, such as HL7’s error condition, which the HL7 acknowledgement then says. A record schema and a set keep all of these with the rule; a Schematron assertion keeps its weight as its role.
The words: is (a value, or the value of another field), is one of (a list of values — where the field has a list of its own, tick them), matches (a pattern, which the whole value must match), is at most and is at least (a number, a date or a time, or another field), is present and is absent. A word that needs a value also needs the field: “postcode matches …” does not hold of a document without a postcode. Only the words that make sense for the field are offered: a part with fields of its own can only be present or absent, and a pattern is for text.
The fields offered are those below the selected part that occur at most once there. The rule itself may stand on a part that repeats: it then holds for every one of them — every order line, every record.
Unique and refers to are said of a field that repeats below the selected part — marked (repeats) in the list — over all of its values together: “every order › number is unique”, “every line › order is one of the order › number”. On a set’s message they hold within one file of it. They are there where a rule is an XPath test — a record schema, a set, XSD 1.1 and Schematron — and not in JSON Schema or SQL. A document is checked against them, and generated example data keeps to them — a value already taken made one next to it, one that refers to nothing set to one it may refer to — or, asked to, breaks one.
How often a variant stands: of a part that repeats and is read one of several ways — a variant chosen by the codes a field of it holds — say that the count of one variant is exactly, at least or at most a number: “the count of OBX of the variant text is at most 1”. On a set’s message it is counted within one file. A document is checked against it, and generated example data keeps to it — lines of the variant left out, or one copied, as often as the part may stand — or breaks it where asked.
How it is kept
In an XSD a rule is an xs:assert, which XSD 1.1 brought; a schema read as 1.0 offers to move to 1.1 instead. In JSON Schema it is an if/then in the object’s allOf — before draft-07, which has no if, the same rule as an anyOf — and in OpenAPI the same, as its version allows. JSON Schema cannot compare two fields, so that is not offered there. In a record schema a rule is one of the record type’s tests, and in a Schematron an assert of the selected rule; a Schematron says nothing of the document, so you type the field names yourself.
A test written by hand in the same shape is read as a rule too, and shown in words. Any other test — free XPath — is listed as written, marked checked only: it is checked like any rule, but the generator cannot keep to it or break it on purpose. Change it in the text.
What reads a rule
Checking: a document that breaks a rule is told so in the Problems panel, with the rule in words: “the rule “When country is NL, then postcode matches [0-9]{4}[A-Z]{2}” is not met here”. Example data: every generated document keeps to every rule, and takes one side or the other of each “when”, so that a set of them shows both; the invalid documents break each rule once, and nothing else. Tests: a proposal makes a test for each side of a rule — its “when” holding and not holding — and coverage counts both.
Rules that cannot hold are said at the schema, as warnings in the Problems panel: a rule whose “when” the schema never allows (a country the list does not have), a rule that can never be met where it applies, and two rules that contradict each other when both apply (“amount at least 50” and “amount at most 10” for the same country). Where a field’s pattern and a rule’s pattern meet, values are tried, and if none is found that is said too — more softly, since trying is not proof.
On the command line nothing is different: schemantix validate says a broken rule in words, schemantix generate keeps to the rules (and --invalid breaks them), schemantix test --propose proposes both sides of each rule, and schemantix diagram shows each rule on its card. Every rule of the schema in one list: the Rules tab below the editor, there whenever the schema holds one, says each rule in words at the part it stands on — a test the words cannot say as it is written, marked *checked only* — and choosing the part selects it; schemantix rules <schema> lists the same, a line to a rule (--json for the rules as the engine keeps them).
Patterns
Regular expressions (pattern, patternProperties, xs:pattern) are checked in the dialect of the format and version: ECMAScript for JSON Schema and the XML Schema dialect for XSD. The two differ — for example, XSD has no anchors ^/$, no lazy quantifiers and no lookarounds, and matches the whole value. A \p{Is…} escape names a Unicode block, and the blocks are the ones the Unicode database this project reads has (16.0.0), so \p{IsAdlam} and everything else added since Unicode 3.1 works; XSD 1.0 is the exception, because that version fixes its own list of names. Try the pattern, below a pattern in the node details, tries it against texts you type, one per line, and says of each whether it matches — in the same dialect and under the same budget as validation, so it says what validation will say of that value; a pattern that risks very slow matching is tried all the same, and a text it cannot settle in time is undecided. A text that does not match says where it stops: the part the pattern took, and the rest marked from the character it could not take — AB12C4 against [A-Z]{2}[0-9]{4} stops at character 5, the C (on the command line, schemantix pattern xsd '[A-Z]{2}[0-9]{4}' --try AB12C4). A pattern that cannot be read is said to be, with what is wrong (an unclosed group, a construct this dialect does not have) and the place in the pattern marked. Under a pattern you are writing, what it says stands in plain words, piece by piece — \d{4}: exactly 4 digits (0–9) — indented where one piece holds others, and following the field after a short pause in typing. The piece at the cursor is marked, in the list and in a copy of the pattern above it, and pointing at a row marks its piece. The words follow the dialect: an XSD \d is a digit of any script and an ECMAScript one is 0–9, and a block says its range. A pattern the dialect cannot read is not explained — Try says why. Typing \p{ offers the names this dialect reads — the categories, XSD's blocks, ECMAScript's properties and scripts; Tab takes one, and Enter still sets the pattern. The same names are offered in the text editor, inside a pattern you write there. On the command line, schemantix pattern <format> <pattern> --explain checks a pattern as validation would and says it piece by piece in these words (--version for another version than the newest).
A JSON Schema pattern is read in Unicode mode, whatever the draft says. So \p{Letter} means a letter and not the four characters p, {, L, }, and a character outside the basic plane — an emoji, say — counts as one character rather than two, in draft-04 as much as in 2020-12. That way a pattern keeps its meaning when a document is converted to another draft. (\w and \d stay what they always were: the ASCII letters, digits and underscore, and the ASCII digits.) A pattern that Unicode mode does not allow but the older, laxer grammar does — \- or \a, say — is still used, and you get a warning saying so rather than an error.
**Two xs:pattern facets side by side are an *either*.** XML Schema counts the patterns written in one <xs:restriction> as a single pattern with a branch each, so a value matching any one of them is a value of the type. Patterns written on *different* derivation steps — a restriction of a restriction — must all match. So to ask for two things at once, put them on two steps, or write one pattern that says both.
- An invalid pattern is reported with the reason and the position in the pattern.
- A pattern that risks catastrophic backtracking (very slow matching on some input) gets a warning.
- In data documents, patterns are also run against the values, in the same dialect. A pattern that could be slow is still run, under a budget that grows with the length of the value: nearly all of them are decided in a moment, and one that does run out of budget gets a warning saying the value went unchecked — never that it is wrong. The warning about the pattern itself stands where the pattern is written, for whoever is writing the schema.
Example data
Schemantix can generate example documents — valid ones, or deliberately invalid ones for testing. How they are generated is kept in a generator profile: a .profile.json file in the workspace, listed under Generator profiles on the left and included when you download everything. Every change to a profile is kept at once.
Generating documents
- Choose Data › Generate example data…. The profile of the active schema opens in its own tab (a new profile is made when there is none).
- Check the general settings (below).
- Click Preview to see the first document, Download for one document — or a zip when you ask for several — or Open in tabs to open them as data documents.
General settings
- What to make comes first, and the rest follows it: example documents that follow the schema, invalid documents that each break one rule, boundary values (documents on each bound, just past it, or both), or a complete test set — every kind at once in one zip, which Download then makes.
- Use cases: the saved sets of rules of the schema, to make documents as; Save the rules as a use case… keeps the ones of this profile.
- Document: the schema, and what to generate a document for — the document root or a named definition (for XSD a global element; for OpenAPI a message or a component).
- How many: the number of documents — for invalid documents at most one per rule, for a test set the number of each kind, and for boundary values not asked, since the schema decides it — and the seed: the same seed and settings always give the same documents; New seed for different ones.
- Fill: Minimal fill, Typical values, Maximal fill, Empty, or Custom — each says under it what it decides. Custom shows the optional parts (all, only what is required, or some at random), how many items repeated parts get (or a random number up to that) and the Depth of optional parts: below that many levels of objects and arrays only what is required is made, and the document says so; empty, the default, sets no limit.
- Values: whether to use the schema’s own examples and default values, or to make up every value from the constraints; and the language of the values (names, addresses, …).
- Differ per field, folded below the settings with how many fields differ: the structure of the schema, where one field can be set apart from the rest — see *Rules per node*.
Values are realistic where possible — names, addresses, postcodes, phone numbers, e-mail addresses, IBANs, dates — based on the format and the name of a property or element, and always stay within the constraints: types, enumerations, bounds, lengths, the number of digits and decimals (XSD’s totalDigits and fractionDigits) and patterns in the right dialect. A date or a time follows XSD 1.1’s explicitTimezone: with a timezone where it is required, without one where it is prohibited. Optional recursive parts are left out: an optional part, an array’s items past its fewest, or a member of a choice that would repeat a part it is inside is not made, so a recursive schema ends without a depth limit, and a deep one is made whole.
A flaw in the schema is stepped around where it can be. An example or a default that breaks the constraints beside it — a code of exactly 8 characters with B0118 as its example — is not used, and the notes say where. A member of an “exactly one of” that requires a name the object cannot have (a property misspelt beside additionalProperties: false) is not chosen while another can be. Where no document satisfies the schema all the same, the notes say so and list what it breaks.
Rules per node
Below the settings is the structure of the schema as a nested grid. In the row of a node you can set:
- whether it is always or never included;
- how often it occurs (at least / at most);
- values to choose from;
- whether its values come from the schema’s examples or from the constraints.
A rule on a definition applies wherever the definition is used. Rows with a rule are highlighted and have a × to remove it; Reset … to the general settings removes every rule. The ⓘ at the end of a row shows what the schema says about the node — constraints, default value, examples and description. Hover to see it; click to keep it open, so you can copy a value.
Fields that belong together
Every field gets its value on its own. With examples on both a city and a postcode, a document can combine a city with a postcode from somewhere else. That does not matter for testing whether documents are valid, but it does when examples must look real — for a demo, say. Give such fields their examples together, on the object that holds them, for instance on the address: "examples": [{ "city": "Amsterdam", "postcode": "1012 AB" }, { "city": "Rotterdam", "postcode": "3012 AG" }].
- With Values from: Examples and defaults — in the general settings, or as a rule on just that object — one of these examples is taken whole, before any of its fields is generated, so the fields always fit together. Everything else keeps its generated values.
- Each example must itself follow the schema of the object. A handful of complete, realistic combinations is usually enough; there is no need to list every combination.
- This works for JSON Schema. XSD has no examples, and the values of a rule are for single values only, so in an XSD every element and attribute gets its value on its own.
Several profiles
A schema can have several profiles, for example one for small and one for large documents: File › New… › Generator profile, or Duplicate in the profile editor (a copy with all settings and rules). Rename… gives a profile its own name. While a profile is active, the node details in the diagram have a Generator tab, and cards with a rule show ⚙.
Invalid documents
A complete test set, chosen under *What to make*, makes Download one zip of every kind of document at once: ones the schema accepts, ones that each break one rule, ones on and just past each bound, and ones for each use case. The schema comes with it, and a test file you run as it is (schemantix test, or the Tests panel), expected.json for any other test framework, and a README saying what each document is for.
With Invalid documents chosen under *What to make*, each document breaks exactly one constraint — a required part left out, a value outside its bounds or enumeration, a text that does not fit its pattern, a wrong type, too many items, and so on. The preview says which constraint is broken; a downloaded zip lists them all in violations.txt.
Which constraint a document breaks is chosen by the seed: another seed, another constraint, and the same seed always the same one. Several documents at once each break a different one. The seed also chooses the wrong value itself: sometimes exactly on the boundary (one character too short, one below the minimum), sometimes further off; a wrong type may be a number, true, null, a list or a number written as text; a value outside a list of allowed values may be a near miss such as Red where red is allowed. The rest of the document stays as it was, so the fault is the only difference.
To put the fault in one particular place, use the column May go wrong in the profile table, or the same setting on the Generator tab of a node:
- Yes, this one — this node may get the wrong value. As soon as one node says this, only the nodes that say it go wrong, and everything else stays correct. Mark one field and every invalid document has its fault in that field.
- Never — this node always stays correct; the others go wrong as usual.
- A node only goes wrong if it is in the document, so give an optional node Include: Always as well. A node that has nothing that can be broken gives valid documents with a note saying so.
Minimal and maximal fill
A layout is tested with the longest and the shortest a document can be: does the text leave its box, does the amount still fit the column, does the address block run off the page? Fill at the top of the settings makes it. Minimal fill puts every field at its least — the shortest text (empty where allowed), the smallest number, the shortest value of a list of values, the earliest date — leaves out every optional part and gives every repetition its minimum. Maximal fill puts every field at its most — text at its maxLength (or a record field’s length), a number on its maximum or, with none, the widest its digits allow (999.99 for five digits with two decimals), the longest value of a list, the latest date (9999-12-31) — includes every optional part and gives every repetition its maximum. Tick Wide characters for text to make text of W, M and @, and in every second document of letters with diacritics and from other scripts (ÅÉÑÜØ…, Greek, Cyrillic, CJK), which finds font, line-breaking and encoding problems at once. Empty leaves out what may be left out, writes an empty text where one is allowed and nought where a number may be nought. A value with a pattern is as long or as short as the pattern lets it be, in its own characters; a value of another format (an e-mail address, a URI) keeps its shape.
A field the schema gives no bound is held to a cap: an unbounded text has no longest value and a number with no digits no largest one, so maximal fill would write a document nobody can assess. The caps — a name 70 characters, a text 255, a number 13 digits of which 2 decimals, a repetition 10 — are under Caps for fields without a bound, and are kept in the profile. Each capped field is listed in the notes: a layout designed without a maximum has been tested against nothing, and that field is usually the one that breaks the page in production. Write as a bound writes the cap into the schema as a real maxLength, maximum or maxOccurs.
A fill can also be set per node, in the profile’s table (column Fill) or in the node details under Generator: At its least, At its most, Widest, Empty or Typical, for that node and everything below it until a node says otherwise. So “the whole document at its most, but the amounts typical” is two settings. On the command line: schemantix generate --fill maximum (or minimum, widest, empty), each capped field said with its cap, and in --json with the bound its fix writes.
Use cases
Testers test “the letter for a Dutch customer with a foreign account”, not “the schema”. A use case is that situation kept in the workspace: a named set of choices over the schema — fixed values, a part present or absent, how often something repeats, how full it is made, and constraints beside the schema’s own (an IBAN that starts with DE, an amount over a thousand) — and for everything else the ordinary generator. Use cases are kept beside the schema in <schema>.usecases.json. To make one, set the rules in the profile’s table (and a Fill if you want one) and choose Save the rules as a use case…: the rules and the fill are kept under the name you give, and a use case of that name is replaced. Constraints are written in the file itself, as "restrictions": [{ "kind": "pattern", "value": "^DE" }] on a node’s rule.
Use cases combine. Tick them under Use cases in the settings and each document is made as all of them together, over the profile’s own rules: “Dutch customer” + “foreign account” + “long note” is one document. Where two say different things of one field — one leaves it out and the other wants it, their values have none in common, their counts do not meet, they fill it differently — the clash is said at once and no document is made. On the command line: schemantix generate order.xsd --use-cases order.usecases.json --use-case "Dutch customer" --use-case "foreign account".
Tests name use cases. A test file’s subject names the file ("useCases": "order.usecases.json") and a generated document names the use cases it is made as ("generated": { "useCases": ["Dutch customer"] }), and a fill of its own ("fill": "maximum"). A run then says which tests cover each use case — “use case *cancelled after confirmation* is covered by three tests” — and lists the unbounded fields: every field a document was held to a cap at, with the tests whose documents they were. The test proposal makes one test per use case, one per pair of use cases that combine (at most 45 pairs), and one document at minimal and one at maximal fill; on the command line schemantix test --propose order.xsd --use-cases order.usecases.json.
Boundary values
Boundary values makes the documents a tester wants at the edges of a schema: for every bound it sets — a minimum or maximum length, a lower or upper numeric bound, the fewest or most items of a list, the fewest or most times an element may occur, the most digits a number may have — a document exactly on the bound and one a single step past it. On the bound means the longest text maxLength allows, the smallest number minimum allows, the first value inside an exclusive bound; past it means one character more, one step below, the exclusive bound itself. A number steps by the schema’s own step: its multipleOf, or in XSD its decimals (fractionDigits 2 steps by 0.01); a whole number by one, and a number nothing steps by half a unit. So minimum 1 with multipleOf 2 stands on 2 and steps past to 0, and a document past a bound breaks that bound and nothing else. With totalDigits the bounds are the largest and smallest number the digits allow — 999 and -999 for three digits, whatever the decimals — and past them is 1000 and -1000, a number with a digit too many. Near a large bound the digits make the step coarser too: three digits leave 500 no room for a decimal, so past a maximum of 500 is 501. The first and last date or time of a range are bounds too: an XSD minInclusive, maxExclusive and the like on an xs:date, xs:dateTime, xs:time, xs:gYear or one of its kin. A date steps a day; a time or a dateTime a second, or the finest decimal its bound writes, so past 23:59:59.50 is 23:59:59.51; a gYear, gYearMonth, gMonth, gMonthDay or gDay its own year, month or day. The step is taken in the bound’s own timezone: a bound with +05:00 gives values with +05:00, a bound without gives values without — unless an XSD 1.1 explicitTimezone says otherwise: where it requires a timezone a bound without one gives values in Z, and where it prohibits one a bound with one gives values without, on the nearest day the bound still allows (a day at -05:00 begins after the same day in UTC, so the first day on or after 2031-01-01-05:00 is 2031-01-02). A bound with nothing past it is no bound here — one second past a time of 23:59:59 goes round to midnight — and year zero, which XSD 1.0 does not have, is stepped over: past 0001-01-01 is -0001-12-31. JSON Schema sets no bounds on a date: its minimum is for numbers alone. Example data, too, now falls inside the bounds of a date. A date or a time with no bound stands on the edges of its type: the twenty-ninth of February of a leap year and of another (2024-02-29, 2023-02-29), the last day of a month and the one after it (2023-04-30, 2023-04-31), the last month and a thirteenth, the last second of a day and one past it (23:59:59Z, 24:00:01Z), a leap second where RFC 3339 has one (JSON Schema’s time and date-time: 23:59:60Z), and the widest offset and one wider — +14:00 in XSD, +23:59 in JSON Schema. A JSON Schema format is an annotation unless its dialect makes it assert, so a reader only warns of a value past an edge: the manifest then says "valid": true, "warns": true rather than claim it must be refused. Choose On each bound, Just past each bound or Both; the number of documents is then the number of bounds, and Invalid documents does not apply. The download holds a list in words and bounds.json: per file the bound, its side and whether a reader must accept it, which a test pipeline reads as it is.
Every document differs from the others in that one value and in nothing else. One on a bound is checked against the schema like an ordinary example; one past a bound breaks that bound and nothing else. The preview says which bound and which side; a downloaded zip names each file …-bound-01-on, …-bound-02-past and lists them all in bounds.txt. May go wrong on a node limits the bounds used to the nodes marked, and Never leaves a node out, as for invalid documents.
Declared tests
A test file writes down, once, what a schema must accept and what it must refuse — the acceptance criteria of a schema, run again after every change. It is a JSON document of the workspace, <name>.tests.json, beside the schema it is about. Show a schema and choose File › New › Test file to start one: it names the schema and holds one test, which you copy and change.
A test
Each test has an id that never changes (the report keys on it, never on the order), a name, free tags, a document it is given, and what it expects of it. The document is given in exactly one way:
"file": "people/ann.json"— a document of the workspace, as a path from the test file’s folder."text": "{\"name\": \"Ann\"}"— the document itself."generated": { "seed": 7 }— a document the generator makes from the schema, with its own settings (optional,repeat,values,locale,rulesper node, or a generatorprofile). The same seed gives the same document."generated": { "invalid": { "constraint": "TOO_LONG", "at": "#/properties/name" } }— a document that breaks one constraint, named by the finding it draws and the schema node, never by its place in the order the generator meets constraints. Edit the schema above that node and the test still breaks the same constraint."generated": { "bound": { "constraint": "TOO_LONG", "at": "#/properties/name", "side": "past" } }— a document exactly on a bound or one step past it, as Boundary values makes them.
What is expected: "valid": true or false; "findings", a list of findings by code, at (the schema node) and count, held with "mode": "contains" (each is reported) or "exactly" (and nothing else is); and "assert", XPath 3.1 assertions over the document (count(/order/line) = 2, ?age > 18), each true by its effective boolean value. A test that expects nothing in so many words checks the default: valid — or, for a document made to break a constraint or step past a bound, not valid. The panel says so of a test that passed on the default alone: covered is not checked.
Running
Choose the test file in the Tests panel and Run tests. Each test is Passed, Failed — with every expectation that did not hold, said with what was expected and what came — or Could not be run: the file it names is not in the workspace, the constraint it was to break is no longer in the schema (the schema changed under the test), or the generator could not make the document it asks for. Click a test to see it in its file. While the test file is shown, Problems lists the failures, each at its test; tests that passed are not problems. A boundary manifest (bounds.json, from Boundary values) runs as a test file too: one test per document, expected valid on the bound and not valid past it.
A generated document is named by the generator’s code for the constraint it breaks, and the validator may name the same fault otherwise: one element too many in XSD is TOO_MANY_OCCURRENCES at the element to the generator and UNEXPECTED_ELEMENT at its parent to the validator. A test expects “not valid” by default for that reason; list the finding you want held, as the validator names it. On the command line, schemantix test person.tests.json runs the same file, with --id, --tag and --json, and leaves with 1 when a test failed.
Proposing tests
Show a schema and choose Data › Propose tests…. Its test proposal opens in a tab of its own (<name>.testproposal.json, beside the schema): the tests a tester writes first, made from the schema, by kind — a document with every optional part and one with none; for each repeating part none, one and many; for each value of a list of values, that value; for each bound, a document on it and one a step past it; for each constraint, a document breaking it alone; for each optional part (a record type, an element), present on its own and absent; for each choice (a record type’s variants, anyOf, an XSD choice), each member taken. Each is a generated document that expects only the default, and each was made and judged before it was proposed: a test the generator cannot make is left out, and said.
Untick a test to leave it out of the test file, or give it another name, which makes it yours. Edit opens its other parts: its tags, whether its document is to be valid, and its document and the rest of what it expects as text, checked before it is taken. Back to proposed undoes that. These decisions are kept in the proposal by what each test covers, not by where it stands, so they hold when you edit the schema and the proposal is made again; a test of yours whose constraint the schema no longer has stays, and its run says so. Write test file writes <name>.tests.json beside the proposal, each test named in your language. Where one is there already, the proposed tests in it are made again and every test you wrote into it yourself stays where it is; a file there that is no test file is not written over. A test whose document breaks something expects the finding the validator gives for it, its code and place, not only that the document is not valid. A proposal is bounded: a list of values gets a test for its first twenty, and a proposal holds at most its limit (200 unless you set another), taken a kind at a time — what was left out is listed below, counted and named. Choose where documents start where the schema has more than one place. On the command line, schemantix test --propose person.schema.json --out person.tests.json proposes the same file, and --proposal person.testproposal.json keeps your decisions.
Pairs and triples: a proposal also combines its factors — each list of values, each choice and each optional part — so that every pair of their values stands together in some test (Pairs 2: country = BE, postcode absent), or, with Combinations set to Triples, every triple; None leaves them out. The schema’s dependency rules are kept — a combination a rule forbids is not asked for — and so is a Schematron the proposal names beside the schema (schematron). Above the tests the proposal says how many combinations there are and how many its tests cover, and why each other one is left out: forbidden by a rule, no document can hold it, past the first twenty values of a list, past the proposal’s limit, or removed by you. On the command line: schemantix test --propose --combinations pairs|triples|none and --schematron <file>.
Tests of a pipeline
A test file’s subject may be a pipeline: "subject": { "pipeline": "orders.pipeline.json" }. A test then gives the principal input as a schema test gives its document — a file, a text, a generated document of the input’s schema — or a sample of the pipeline by name ("sample": "two orders"); "inputs" gives the other inputs by id, each a file or a text, and "parameters" values by name. By default it expects the run to end well and every output to validate against its schema. Besides: "assert" tests the principal output with XPath, where `$input` is the principal input (JSON, YAML and record files as XML, as the pipeline reads them); "output" compares the output with an expected document (a file or a text, optionally only the part a "select" picks) — "mode": "exact", "unordered" (the order of siblings does not count) or "whitespace" (whitespace does not count) — and a test that fails says how many differences there were and the first five, each with where it is, what was expected and what was found; "faults" expects what the error policy wrote ("count", "codes"); and "outcome" how the run ends ("ends": "succeeds" or "stops", with a "code"). A pipeline test always runs with the engine’s own settings, not yours, so it gives the same verdict everywhere.
In the pipeline editor, Samples as tests writes a test file beside the pipeline with one test per sample (run again, it adds only the samples it lacks). The Tests panel and Run all tests run pipeline tests too, and the pipeline’s documentation lists its test files with the latest run. On the command line: schemantix pipeline test orders.tests.json (or schemantix test), and schemantix pipeline document --tests orders.tests.json. A run says what of the pipeline its tests reached: every step, both ways of every filter and split, every branch of a choice, each error policy met, each lookup found and not found, which optional parts of the target schema were produced, and for each step how many items it processed and how long it took. --coverage names what no test reached. Propose tests in the pipeline editor (or schemantix test --propose orders.pipeline.json) proposes a test for each way of every condition, a found and a not-found code for each lookup and each fallback, each found by running the pipeline; what no document reached is left out and said. *Add a test* beside what a run left uncovered does the same for that one thing, and Settings can run the tests with a tag every time you save.
Coverage
After a run the Tests panel says what of the schema the tests’ documents covered: each optional part (a record type, an element, a JSON Schema property) present and absent — absent only where what holds it is there — each value of a list of values, each member of a choice (a variant, an anyOf member, an XSD choice) taken, each part that repeats held none, one and many times, and each bound (a length, a count, a number, a date) stood on and past — counted per kind, and the targets no test covered listed by name and by the place in the schema they stand at. The targets are what Propose tests would make a test for, so Add a test beside one adds that test to the test file, named in your language, and Add a test for each adds one for every target left; run the tests again to see them count. Every document a test ran on counts, whatever it was expected to be; one the generator could not make as asked does not. An uncovered target is no fault of the schema, so it never stands in Problems. On a very large schema the work may run out before every target is looked for, and the panel then says so.
Tick Show on the diagram to see it on the schema: a card with targets carries how many of them the tests covered — green when all, amber when some, red when none. On the command line, schemantix test says the same figure after the count; --coverage lists what no test covered, --json holds all of it, and --propose-uncovered adds a test for each uncovered target to the test file (or to --out).
Exporting a test set
Over a test file, Export as a test set… saves its tests as a zip that runs anywhere: each test’s document a file of its own — a generated one made as a run makes it — in a folder by what is expected of it (valid, invalid, bounds, under <name>-documents/ beside the test file), the test file written again to name those files and to say of each test whether its document is to be accepted, the schema and the documents it includes, expected.json for any other test framework, and a README in your language. Run as it is, the set comes out as the test file did. A test whose document cannot be made (a file it names is missing) is left out, said beside the button and listed in the README; the tests of a pipeline cannot be exported yet. On the command line: schemantix test person.tests.json --export <folder>.
Reports
After a run, Download report in the Tests panel offers the run as a report in your language: HTML, one page to read or send that fetches nothing when it is opened, and JUnit XML, the file a build server reads. Both say which schema was tested and as which version, when the run was made and by which version of Schemantix, each test with its outcome and why — the tests that did not pass first, then those that did, with what each checked and what the validator reported — the tests that passed on the default alone, the coverage with what no test covered, and the SHA-256 of the test file, of the schema, of each document the schema includes or imports and of each file a test was given, so that a report shows what was tested byte for byte. In the JUnit file every reason is also a code — a failure’s type, and a property schemantix.reason.<id> per test — so a build can read it without reading the words; an error of the test file itself counts as a test of its own, so a file that runs nothing is not a green build.
Each test says how long it took, what the generator said of the document it made, and why a document could not be read. Where the workspace holds more than one test file, Run all tests runs them all and offers one report of them all — a section, or a JUnit test suite, per file.
On the command line, schemantix test person.tests.json --report html --out report.html writes the same report, byte for byte, in the language of --lang; --report junit writes the JUnit file. Without --out the report is written to the screen in place of the lines. The exit code is the same either way. Name several test files (schemantix test a.tests.json b.tests.json) for one report of them all; a run filtered by --id or --tag names in the report what it left out.
Proposing a schema from data
Have example documents but no schema yet? Schemantix can propose one from them. Open the documents (see “Data documents”) and choose File › New… › Schema › Proposed from sample data, ticking the documents to use (or Choose files… to open more). JSON documents propose a JSON Schema, XML documents an XSD. The proposal opens in its own tab: a .proposal.json file in the workspace, listed under Schema proposals on the left and included when you download everything. It keeps which documents it uses, the settings and your decisions, so you can come back to it — also after adding documents.
How a schema is proposed
- A property is required when every object at its place has it and at least two documents show it; otherwise it is optional. So a schema proposed from one sample has nothing required until a second sample shows it — one file cannot tell a property that is always there from one that happened to be there. Required only when seen in at least this many documents in the settings changes the two; a proposal saved before that rule keeps the rule it was made under, one document.
- Its type is what the documents have there (
integerandnumbertogether makenumber);nullnext to other values allowsnulltoo. - A list gets the schema of all its items together.
- From XML: an attribute becomes an attribute and a child element an element, text beside child elements makes the type mixed, and an element name that occurs more than once in the same element anywhere is a list everywhere (
maxOccurs="unbounded"). The elements are put in an order every document agrees with. Text that is plainly a whole number or a decimal becomesxs:integerorxs:decimal;007stays text. - Formats — date, time, date and time, duration, e-mail address, UUID, IP address, URI — are proposed where every value has one (and the chosen version knows it).
- Allowed values (
enum) are proposed where a few values keep repeating — only when switched on in the settings, because with few documents they are the most misleading. - A few values are kept as
examples, which example-data generation can use. - An object shape that repeats — a billing and a delivery address — is named once, as a definition both places refer to (in an XSD a named type), unless Name a shape that repeats once is switched off.
- Objects at one place that come in kinds —
{"kind": "card", "number": …}beside{"kind": "transfer", "iban": …}— are proposed as a choice of the kinds: a property every object has, a short text of two to eight values, where objects of one value hold properties those of another never do, becomes the discriminator, and each kind is a member of aoneOfwith that value fixed and the properties all its objects have required. Objects that come in kinds switches it off (propose-schema --no-variants).
Every decision is checked against the documents at once: the list of documents says for each whether it fits the proposal, and if not, what the first problem is. Make a property required that one document lacks, and you see which one no longer fits.
Changing the proposal
The structure seen in the documents is a nested grid, with the proposed schema next to it. In the row of a place you decide whether it is Required, its Type (As seen follows the documents), whether null is allowed, its Format (Automatic follows the documents) and whether only the values seen are allowed (Enum, for places with few, single values). Changed rows are highlighted and have a × to go back to what the documents show; Reset … decisions takes back all of them. The ⓘ at the end of a row shows what a decision is based on: in how many objects a property is present and in which documents it is missing, the types and values seen (how often each), the formats every value matches, and how long lists are.
- Data documents: tick the documents to learn from — at first all documents of the workspace with the same syntax (a proposal describes either XML or JSON, never both).
- Settings: the version (a JSON Schema draft, or XSD 1.0 or 1.1), whether to propose formats and allowed values (and at most how many), whether to keep examples, and whether objects allow other properties than the ones seen.
- Open as schema opens the proposed schema as a new document (named after the proposal:
person.schema.json, ororder.xsdfor an XSD), to go on with in the text or the diagram; Download schema saves it.
A proposal can only show what the documents contain: “required” means “in every document”, and a handful of documents easily makes a proposal too strict. Use documents that differ, and check the decisions that matter.
Where it is still guessing
A proposal says what it does not know. A place the documents could not settle has a ? beside its name — hover it, or open its ⓘ, for why: present every time, but in too few documents (kept optional; Make it required is one click), seen in one document only (assumed required under a setting of one document; Make it optional), always the same value (a constant, or one code of a list?), a few values, repeated (a code list? tick Enum), no list here was empty (empty lists are allowed, though none was seen), or every list held one item (is it a list at all?). The ⓘ also says in how many of the documents the place was seen. A decision you take settles the question, and the mark goes. With one document the proposal asks for more: Add samples… opens more files into the workspace and the proposal, which is proposed again with every decision kept.
An XSD proposal is built as a JSON Schema and converted, as Convert to does (see “Versions”). What XML Schema cannot express is named above the settings — for example an element that is text in one document and has children in another — and the documents that no longer fit say so, so you can see what to adjust by hand.
Namespaces
Names keep the prefix your documents write them with (o:line, @xml:lang), so the places you decide about are the names you know. The namespace of the document element becomes the targetNamespace of the proposed XSD, declared with the same prefix your documents use (xmlns:o="urn:shop") and with elementFormDefault="qualified"; a default namespace (xmlns="urn:shop") gets a prefix of the schema's own (tns). In the XSD itself the names are their local part, as XML Schema writes them.
- One schema document describes one namespace, so names from another namespace are described in the schema of that namespace: the main schema imports it (
<xs:import namespace="urn:x"/>) and refers to its names (<xs:element ref="x:extra"/>). Those schemas are named under the proposed schema (order.x.xsd (urn:x)); Open as schema opens them all — the main one in front, the others beside it, so the references resolve — and Download schema writes them together as a zip. - Only what no schema can declare stays open:
xml:langand the like belong to the XML namespace, which is bound by definition and described by the W3C. They becomexs:anyAttribute(orxs:anyfor an element) and are named above the settings, so your documents still fit the proposal. - An attribute without a prefix belongs to no namespace, as XML has it; an element without one belongs to the default namespace where your document declares it.
- A JSON Schema proposed from XML documents keeps the names as written (
o:order) and writes the declarations alongside: JSON Schema has no namespaces.
Searching and calculating (XPath, XQuery, JSONPath, FHIRPath)
The Query tab next to Problems (below the editor) runs a query on the document shown: a data document, or the active schema — an XSD is XML and a JSON Schema is JSON, so schemas can be queried too. Type the query and press Enter or Run.
- XML documents take XPath or XQuery; JSON documents JSONPath, XPath or XQuery (choose beside the query, together with the version: XPath 1.0, 2.0, 3.0 or 3.1).
- A FHIR resource, in JSON or in XML, also takes FHIRPath 2.0 — the language of FHIR’s own rules:
Patient.name.where(use = 'official').given,Observation.value.ofType(Quantity).value > 100. Each result says where it stands (Patient.name[0].given[1]); a name the resource’s type does not have is an error that says so, and a choice is reached by its name andofType(). - Parts of the document that are found are listed with their place —
/order/line[2]/@qtyor$['lines'][1]— and marked in the text. Click a place to go there. - Calculated values (a sum, a date, a text) are listed with their type, such as
xs:decimalorxs:date. - When several numbers are found, a line below shows how many, their sum, the smallest, the largest and the average. These are exact:
0.1and0.2add up to0.3. - Up to 1000 results are listed; the count and the totals cover all of them.
- A value longer than 200 characters is shortened. Tick Whole values to see each one whole: an element is then shown as the XML it is, and a map or an array as JSON — what you copy to use elsewhere.
What can be written
While you type, the field offers what can stand at the caret: the names the document itself holds — under the step before the caret, so /order/ offers what lies in order and @ offers the attributes of that step — the axes of a step, the functions of the chosen version with what they take and answer (round($value as numeric?, $precision as xs:integer?) as numeric?), and the types a cast may name after cast as or instance of. A name that holds nothing (the end of a branch) offers no names: nothing leads on from it.
- Use ArrowDown and ArrowUp to choose, Tab to write the one chosen, Esc to close the list. A function is written with its opening bracket, ready for its arguments. Enter runs the query, whatever the list offers — in a field that exists to be run, Enter can mean nothing else.
- A JSONPath property that holds a list is written with its brackets,
lines[], the caret between them; there, and after a[you type yourself, the list offers its places —*for every item, its numbers from0with how many items it holds, and-1for the last. XPath offers the same after an element that stands more than once: its numbers from1, andlast(). A long list offers its first ten numbers and its last. - Clicking a line in the list writes it as well.
- The names come from the document as it stands, so they are paths that lead somewhere; after
//(or..in JSONPath) every name of the document is offered, because such a step reaches everywhere. - For a record file the names come from the tree its schema makes of it — the record types at the outside of the document, the fields of a record under its name — since nothing in the file itself says what its lines and columns are called. The file has to be paired with a schema for that, which is the same condition running the query has.
Queries you ran before
Every query you run is kept, the most recent first: the ⟲ beside the field shows them, and choosing one writes it back in the field with the language and version it was written for. The fifty newest are kept, per browser (not in the workspace), and the same question in the same version stands there once. Throw one away with the 🗑 beside it, or all of them with Forget these.
Which version of XPath
Applications speak the version of XPath they speak: 1.0 in many XML tools, 2.0 or 3.0 in others, 3.1 in the newest. Choose the version beside the query, and the field follows it: only the functions that version has are offered, and what you write that it does not have yet is said under the field — “The function matches (at position 1) came in XPath 2.0; you are writing for 1.0”. So a query you write here also works where it is meant to run.
- Queries are run by the XPath 3.1 engine whatever version they are written for, so you see an answer either way. 3.1 holds everything the older versions have; in a few corners the standards differ (XPath 1.0 compares
'10' > '9'as numbers, later versions as text), so check such a comparison in the application itself. - The version is about what may be written; the document and its namespaces are the same in every version.
- A function the standard does not hold — one of the application itself — is not judged: nothing is said about it, rather than a version guessed for it.
XPath
XPath finds and calculates: //line[@qty > 2], count(//line), sum(//line ! xs:decimal(@price)), xs:date(/order/@date) + xs:yearMonthDuration('P1M'), for $l in //line return upper-case($l), if (count(//line) > 3) then 'large' else 'small', string-join(//line/@sku, ', '), and the other functions of the XPath 3.1 standard.
- Every prefix the document declares can be used (
//x:extra). Names without a prefix mean the namespace of the document element, so/order/lineworks in a document with a default namespace. - As in every XPath engine, text counts as a double in arithmetic:
sum(//price)may show21.939999999999998. For exact decimals writesum(//price ! xs:decimal(.))— or select the prices themselves (//price) and read the totals line. - In a JSON document, the document is a map:
?lines?*?pricefinds the prices,sum(?lines?*?price)adds them up. Found values have no place in the text; use JSONPath for places. - The XPath engine is loaded the first time you run an XPath query, which takes a moment. A query that runs longer than Patience allows (Settings › Advanced settings › Queries and transformations) — twenty seconds to begin with — is stopped. An expression that will not end cannot be interrupted, so stopping it means ending the engine’s worker, and anything else it was working on at that moment is lost as well; the next query starts a fresh one. Give it more seconds there if you ask it something that needs them. Stop, beside Run while a query runs, ends it the same way at once — which is also why Patience can be set to No limit: a query that will not end is then ended by hand.
- A year in a date or a time must fit in 32 bits — just over four thousand million, either side of year nought. Further out than that the engine will not say a date is a date, since it could no longer tell you which of two such dates is the earlier. The standard leaves where that line runs to each engine.
XQuery
Choose XQuery 3.1 beside the query to write a whole query rather than a path: a FLWOR (for $l in //line where $l/@qty > 2 order by $l/@sku return $l/@sku), with let, group by, count and windows, typeswitch, switch, try { … } catch * { … }, and new XML written as XML (<total sum="{sum(//price)}">{count(//line)}</total>) or computed (element total { … }). A prolog may stand before the query: namespaces, variables and functions (declare function local:net($p) { $p * 0.79 };).
- The field takes several lines: Enter starts a new one, and Ctrl+Enter (or Run) runs the query.
- Nodes found in the document are listed with their place, as for XPath. Nodes the query makes stand nowhere in the document, so they are shown as the XML they are.
- XQuery modules of the workspace (
.xq,.xqm,.xql,.xqy,.xquery, opened like any other document and listed under XQuery modules) are whatimport module namespace m = 'urn:m' at 'lib.xqm'finds: the one of that namespace, and of those the one whose path ends with theathint. - Below the results, Written out shows the whole result as the query asks it to be written — by its
declare option output:…declarations (output:method,output:indent,output:item-separator, …), and as XML where it says nothing. - XQuery is schema-aware:
import schema namespace s = 'urn:s'finds the workspace's XSD of that target namespace (or the one itsathint names), and its types and declarations can then be cast to, tested withinstance ofandelement(*, s:T), and asked of a document;validate { … }checks a node against the schema and gives it back typed, and an invalid one is the error XQDY0027. - Static typing is a mode of its own (*Settings › Advanced settings › Queries and transformations*, off by default): the type of every expression is worked out before the query runs, and a type error is said then. It is pessimistic, as XQuery’s optional feature is —
abs(//a)is refused, since//amight be more than one element. On the command line,schemantix query --static-typing. - A large document is read once, for XPath and XQuery alike: reading it is nearly all a question costs — about two seconds over ten megabytes of XML — so it is kept while its text is unchanged, and every question after the first takes about a quarter of the time. Kept, it takes about twenty-five times its size in memory, one document at a time. Where your documents are so large that memory runs short, turn Queries: keep the document between questions off under *Settings › Advanced settings › Queries and transformations*.
- An error gives its XQuery code, such as “XQuery error XQST0118 (at position 12). An end tag does not match its start tag.”
JSONPath
JSONPath (RFC 9535) finds parts of a JSON document: $.lines[*].sku, $..price (anywhere), $.lines[0], $.lines[-1] (the last), $.lines[0:2], $.lines[?@.qty > 2] (a filter), $.lines[?@.sku == 'a' || @.qty < 1]. The functions length(), count(), match(), search() and value() can be used in filters, such as $.people[?match(@.email, '.*@example\.nl')]. A name with other characters is written in brackets, without a dot before it: $['$defs'], $['ns1:Envelope'].Header — a name an XML document was written as JSON with, prefix and all, is one, and so is every attribute ($['@id']). Written with a dot, the query says so and offers to write it right.
An error says what is wrong and where, for example “The query is not written correctly at position 9” or “XPath error XPST0081 (at position 3). A prefix is not declared in the document.”
Transformations (XSLT stylesheets)
An XSLT stylesheet says how a document is turned into another document. In Schemantix a stylesheet is a document of the workspace like any other: it has its own tab (marked ⇥), it is listed under Stylesheets on the left, it is saved and downloaded like the rest, and it comes back when you return. The Transformations menu in the toolbar makes a new one, opens one from your computer, and switches between the ones you have open.
Checked against the version it declares
A stylesheet says which version of XSLT it is written for (version="1.0", "2.0" or "3.0" on xsl:stylesheet), and that is what it is judged by. The version is shown above the text. Everything that is wrong is underlined where it stands and listed in Problems; clicking a finding takes you to its place. The check runs when you open a stylesheet, when you show it, and after a pause in typing — the text is never locked.
- An element XSLT does not have (a typo such as
xsl:template-group), or one that only exists from a later version —xsl:for-each-groupin a stylesheet that declares 1.0. - An element where it may not stand: an instruction between the declarations, a template inside a template, an
xsl:whenoutside achoose. - An attribute the element cannot do without (
xsl:call-templatewithoutname), one it is not defined with, or one that only exists from a later version (separatoronxsl:value-ofbefore 2.0). - An attribute written with a value it cannot have:
indent="true"where XSLT allowsyesandno,method="XML"where it isxml. Only attributes whose values the standard names in full are judged this way. - A name that is no name XML can write, a prefix kept out of the result that is not declared, or a collation this editor has not got.
- A name written with a prefix that is not declared where it stands, a
modethat is no list of names, two parameters passed side by side under one name, or anxsl:numberthat is both given a value and asked to count. - An attribute that takes whole numbers with something else in it (
start-at="1..2"onxsl:number), or one that takes a single character with more than one (decimal-separator=".."). - A template with neither
matchnorname: nothing can ever reach it. - An element that cannot do without a child it does not have (
xsl:choosewithout anxsl:when), something written in an element that holds nothing at all (xsl:output,xsl:number), or text in an element that takes only the children written for it. - A child that stands before every other one and does not: an
xsl:paramafter what the template does, anxsl:sortafter what it sorts, anxsl:importafter another declaration. - The same name declared twice — two templates, two global variables or parameters, two functions.
xsl:call-templatenaming a template this stylesheet does not have, andxsl:with-parampassing a parameter the called template does not declare.- An element that says for itself whether it belongs (
use-when) is left unjudged, and so is everything written in it: whether it belongs is worked out when the stylesheet runs. - Templates applied in a mode no template is written for, so nothing would be applied in it.
- Both
typeandvalidationwritten on one element: the two ask for different things, so whatever the processor, one of them has to go.
A stylesheet is checked together with the stylesheets it imports or includes (xsl:import, xsl:include) and the ones that import or include it, as far as they are open in the workspace: a template, attribute set, character map or mode declared in any of them counts as declared. When all of them are open, a name declared in none of them is an error. When one is not open, Schemantix cannot know what is in it, so such a name is only a warning. On the command line, schemantix validate reads the stylesheets it imports and includes from beside it.
Versions this editor does not know
If the stylesheet declares a version this editor does not know (version="4.0"), it is read forwards-compatibly: it is said once that the version is unknown, and everything the editor does not recognize is left alone — a stylesheet for a newer XSLT may hold what this editor has never heard of. A simplified stylesheet (an ordinary element such as <html xsl:version="1.0"> instead of xsl:stylesheet) is read as the one template it is.
The XPath in your stylesheet
Everything that holds XPath — select, test, match, use, group-by, and every {…} in an attribute of an element of the result — is read by the same engine that answers queries. What it cannot read is underlined where it stands and listed with the position in the expression: match="line[@qty > ]" says so at once. Only unreadable XPath is reported: a variable you declare, key(), current() or a function of your own namespace are all yours to declare, so nothing is said about them.
What the editor offers while you write
Typing <xsl: offers the elements that may stand there — in the body of a template the instructions, in the declarations the declarations — and only the ones the declared version has: a stylesheet that says 1.0 is never offered xsl:for-each-group. Choosing one writes its end tag as well. In a start tag the attributes of that element are offered, the ones it cannot do without first, and an attribute that is already written is not offered again; choosing one writes its quotes and, where the attribute takes a handful of values (method, indent, order), offers those next. The names are written with the prefix your document binds to the XSLT namespace.
Running a transformation
Transformations › Run a transformation… runs a stylesheet over a document of the workspace — an XML document, a schema (an XSD is XML too), or a data file that is no XML once a schema says how to read it (see below). The result opens in a tab of its own, named after its document, and you save or download it like any other. It remembers how it was made, so closing its tab loses nothing: it belongs to their project under Projects, its bar says what made it, and Run again makes it again from the stylesheet and the document as they are now. A pipeline’s output has the same bar, and Run again runs the pipeline again with the settings it was run with. A run whose files you picked in the dialog is run again from the dialog. The result is written as your xsl:output asks — XML, HTML, XHTML, text, JSON or adaptive — with its parameters as the serialization standard defines them; what cannot be written as asked is refused, and the message names the parameter. Saving writes the file in the encoding its declaration names. What the stylesheet says with xsl:message appears below, and terminate="yes" stops the run; a mode that asks to be warned (warning-on-no-match, warning-on-multiple-match) says so in the status bar. More options asks what the command line asks: the stylesheet’s parameters (name=value, one to a line), a named template or a mode to begin in, the HTML version and package versions to fall back on, the XSD version of a schema the stylesheet imports, whether xsl:assert is checked, and whether a document() that cannot read a file stops the run. Stepping through a run asks the same.
Validating the document. A document paired with a schema — the Schema box above its text — is checked against that schema before the run, exactly as it is checked while you look at it, so what is found is what its Problems list. The schema is always that pairing: not one the stylesheet imports with xsl:import-schema, and not one the document names itself with xsi:schemaLocation. The dialog’s Validating the document has two answers. Strict, where it starts, does not run a document that is not valid, or that its schema could not check — its version not chosen yet, its text unreadable, the schema not in the workspace: the dialog says why, and the document’s tab is shown with what is wrong in Problems. Lax runs it all the same, and the status bar says beside the result that the document is not valid, or was not checked. The dialog starts from the setting XSLT and pipelines: validating the document first under Settings › Advanced settings › Queries and transformations — strict unless you chose lax there — and what you choose in the dialog is for that run alone. A document the application paired by itself, with the only schema that fits it, is validated lax until you choose a schema for it or keep that one: Keep beside its Schema box, or Keep this pairing in the dialog. A schema you chose, and one the document names, is no guess. A document paired with no schema is not validated, and the choice is not shown. On the command line it is --validate-source strict|lax beside --schema, or SCHEMANTIX_VALIDATE_SOURCE=strict|lax for every run, strict unless you say lax. A validated document reaches the stylesheet typed: data() gives a number for an element of a numeric type, and instance of element(*, o:Order) and schema-element(o:order) answer by the schema’s types — which the stylesheet names by importing the schema with xsl:import-schema. Under Lax the parts that are not valid are read as xs:anyType (an element) or untyped (an attribute), which is what XPath’s data model makes of a document that did not validate. Under a mode that streams, a valid document is still read a part at a time, each part validated and typed as it is read; one that is not valid, run under Lax, is read whole, since which of its parts count as valid is a question about the whole document.
How long a run may go on. A transformation or a pipeline run is stopped after so many steps — an instruction run is one step — so that a stylesheet that never ends, one that applies itself without end, cannot run for ever; it then says *The transformation went on too long and was stopped*. In the browser the bound is two million steps. On the desktop and on the command line it grows with the input — two million and ten for each byte of what the run is given — so a large file is not stopped for its size: a run over 64 MB of XML goes to its end. On the desktop the setting XSLT and pipelines: most steps of a run under Settings › Advanced settings › Queries and transformations offers Grown with the input, where it starts, No bound, or a number of your own. On the command line it is --max-steps <n> on transform and pipeline run, 0 for no bound.
The engine is Schemantix’s own and runs XSLT 1.0, 2.0 and 3.0, measured against the W3C’s own test suite (the product overview gives the figure): templates and modes, grouping, keys, accumulators, merging, your own functions, maps, numbering and the formatting of numbers and dates, several result documents, and for XSLT 1.0 stylesheets the common module of EXSLT. Two things that surprise people: a key() searches the document of the node you are standing on (name another as its third argument), and inside an xsl:function there is no context node, so pass in the node you want. doc(), document() and collection() read documents of the workspace (collection('data?select=*.xml'), with ;recurse=yes for the folders below); nothing is fetched from the network. What this engine does not run yet, the Problems panel says before you run it, where it stands in the stylesheet; an instruction it cannot run stops the transformation rather than making half a result. Streaming: an xsl:source-document streamable="yes", or a mode that says streamable="yes", is read a part at a time where its path only goes down (ITEM, DATA/ITEM, .//ITEM); anything else is read whole and gives the same answer in more memory. Under Settings › Advanced settings › XSLT: streaming you choose what happens to a part that asks to be streamed and that XSLT 3.0’s rules do not guarantee: Strict (the default) refuses it, Extended streams it wherever this engine can and marks each place with a warning, Off reads every document whole. The run dialog offers the same choice for one run.
Documents to read in pieces. When you run a transformation, a file added under Documents to read in pieces is not opened into the workspace. A streamable xsl:source-document that names it reads it a block at a time, so a document larger than this tab could hold can still be transformed — and one that asks for validation or type too, validated as it is read, each part typed as the whole document validated would type it. Anywhere else — doc(), document(), unparsed-text(), or with streaming off — it is read whole, within 10 MB a file and 50 MB for all such files of one run; past that the run stops and names the file. fn:stream-available answers for such a file from its first pieces. The file is read in the encoding it is written in — by its byte-order mark or its XML declaration, otherwise UTF-8 — and the stylesheet asks for it by the name the dialog shows.
Expressions are read as XPath 3.1, whatever version the stylesheet says — as in the Query tab. A transformation that will not end (a template that applies itself) is stopped rather than left running: by the engine’s own bound on how many instructions it will run, and by Patience under Settings › Advanced settings › Queries and transformations, which is the wall clock the whole thing runs under. Step through it runs under the same clock and is the slower way to run the same transformation, because every step writes down the variables in scope — so a deep stylesheet that comes back with nothing is worth trying again with more seconds. While it runs, Stop in the dialog ends it at once, a result being written straight to a file included.
Schemas in a stylesheet
The processor is schema-aware. xsl:import-schema brings in the types and declarations of an XSD: one in the workspace, named by schema-location relative to the stylesheet, or one written inside the declaration itself. The schema of the XML namespace (xml:lang, xml:space) and the schema for JSON written as XML are known without a file. What the stylesheet builds with validation="strict" or "lax", or with a type, is checked against them — an element that does not fit is refused with the standard’s own code — and it then carries the types it was checked as, so instance of element(*, my:order), schema-element(my:order), a mode declared typed="strict" and an as naming a declared type all mean what they say. A schema that is not in the workspace is not found; that is no error in itself, and a name the stylesheet uses from it is refused where it is written. The document you run the stylesheet over is read as it is, without being validated: an element in it is untyped until the stylesheet validates a copy of it.
A document that is not XML
A data file that is neither XML nor JSON — a record file of fixed positions, a CSV — can be transformed as well, once you have chosen a record schema for it beside the document (the Schema box above the text). The stylesheet then runs over the tree that schema makes of the file: one element per record, named as the record type is named, one child element per field, named as the field is named, and the records nested as the schema nests them. So header/sender is the sender of the header record, count(order/line) counts the lines of an order, and a field the file left blank where blank means absent is simply not there, so a path asking for it finds nothing. document-uri(.) is the file’s own name, exactly as it is for an XML document.
Until a schema is chosen, such a file is not among the documents you can transform, and the dialog says which files those are: nothing in the file itself says what shape it has, so without a schema there is no tree to run a stylesheet over. The reading is the forgiving one — a line that fits no record type, or a value that does not match its field, is read as far as it goes. But the file is validated against that schema before the run, as every paired document is (see “Validating the document” above): under Strict a file with such a line is not run, and Problems says what is wrong with it; under Lax the transformation runs over what was read.
A record file is read whole before the transformation begins, so it costs its own size in memory. The part-at-a-time reading an xsl:source-document streamable="yes" can get is for XML only; there is no such reading of a record file.
A record file as the result. A stylesheet writes XML, and a record schema writes that XML as a record file, so the two together make one: write the result in the shape the record schema reads — one element per record, named as its record type, one child per field — and convert it with schemantix transform in.xml --stylesheet to-records.xsl | schemantix convert - --schema out.record.json --to record --out out.txt, or in the application by opening the result and choosing Data › Write as a file of …. A transformation pipeline whose target is a record schema writes the record file itself. There is no output method of our own for it: a stylesheet stays one that any XSLT processor runs.
Querying a stylesheet
A stylesheet is XML, so the Query tab searches it like any other document: //xsl:template/@match lists the patterns, count(//xsl:call-template) counts the calls. See “Searching and calculating”.
A stylesheet that builds on others runs with them: xsl:import and xsl:include are looked for among the stylesheets of your workspace, so open them too. A stylesheet that builds on itself — directly, or round through others — is refused rather than read once and run, and the refusal says how it went round, which is what you need to undo it. What is included counts for exactly as much as the stylesheet that includes it; what is imported counts for less, so your own template wins and xsl:apply-imports falls back to the one you imported. A stylesheet that is named but not open is said to be missing — running with half a stylesheet would quietly make the wrong result.
Everything is judged by the version your stylesheet declares: xsl:sequence in a stylesheet that says version="1.0" is refused, just as XSLT refuses it. A version this editor does not know is read as leniently as possible.
Stepping through a transformation
Beside Run in Transformations › Run a transformation… stands Step through it. It runs the same transformation over the same document and writes down what it did, step by step; the Debugger tab below the editor then walks what it wrote. The stylesheet and the document it runs over are put side by side in two windows, so following an instruction or a node goes to it in its own window and the other stays where it was; close the second window as any other. Because the run is over before you step at all, you can step backwards as freely as forwards — there is nothing to run again.
- Each step is one instruction entered or left. What it shows is where the instruction is written (click in … to go there; the stylesheet marks it), which node of the document it is standing on (click the place to go there; the document marks it), the variables in scope with what each holds, and the result as it stood at that moment.
- Where in the document is shown as the way down to the node: the document, then each element on the way —
order › lines › line [3 of 1 200] › @qty— each one click away. One of a row of the same name says which of how many it is. A deep way folds in the middle (… opens it); the end never folds, because the end is what tells one step of a loop from the next. Below it a little tree shows the node among its neighbours — two on either side, the rest counted — and what it holds, folded by name (1 200 × line); a long value shows its beginning and how many characters it has, so a large block of data never fills the panel. A node in another document, or in a tree the stylesheet built, is said to be so, with its path. A run over a record file is shown the same way: the file, the record — which of how many of its kind — and the field, each a click away in the file. Where the document is paired with a schema, each step also says which declaration of that schema it stands on —line : LineType, or an arrow ↗ where its type has no name — and a click on it shows the declaration in the schema. - Into goes one instruction further in, over past what this instruction does to where it is left, and out of the instruction it stands in. Back is one step the other way, whatever its depth. ⏮ returns to the beginning and ⏭ goes to the end, where the result is the whole result.
- ⚠ goes straight to the instruction the transformation stopped at, where it stopped at one, and the refusal is shown at the top — the same sentence you would get from Run.
- Inside lists the instructions you are standing in, outermost first, each with what it walks or tests and the node it stands on — with which of how many, for a loop. With nested loops this is where you see every level of your place at once. Clicking one goes back to where it was entered.
- Result so far is what had been written by that step, with what this step made marked at its end. A long result shows its last part; the rest is one click away. What is built into a variable, an attribute or a message is not part of the result, and a step that builds one says so rather than showing it as though it were. The result, the breakpoints and a variable you follow are three tabs beside Inside, so one shows at a time.
Fix something in the stylesheet and press Run again: it lands back on the instruction you were looking at, where the stylesheet still holds it. It is found by where it stands in the stylesheet — which element of which element — and not by its line, so adding or removing lines above it loses nothing. If you deleted it, you are told so and start at the beginning rather than being put somewhere you did not ask for. And a re-run that could not be made at all leaves you what you had — the recording, your place in it, your breakpoints — and says why, rather than emptying the panel and telling you that nothing ran.
A long transformation is recorded only so far: the engine says how many steps it keeps, and if the run took more you are told at once that what you are looking at is the beginning of it and not the whole. Nothing is recorded for an ordinary Run — a transformation nobody is stepping through is exactly the transformation it always was. And a recording that comes back empty, with the run said to have gone on too long, may be the clock and not the stylesheet: recording is the slower way to run the same transformation, and Patience under Settings › Advanced settings › Queries and transformations is what it has to finish within.
Why a branch chose what it chose
A branch that ran is in the recording because it ran; a branch that did not run was never entered, so it used to be in the recording nowhere at all — you could see which xsl:when ran and never why the two above it did not. So every branch that is asked is a step of its own now, taken or not.
- An
xsl:ifand anxsl:whensay the test as you wrote it and what it came out as. A test that could not be worked out at all says so, with the reason as a code in your own language — which is exactly the step you want when a transformation stopped there. - An
xsl:otherwisesays the one thing nothing else can: that it was reached, which means every test above it came out false. - An
xsl:catchsays which errors it answers for, what was actually raised, and whether it ran. Those last two are not the same question: a catch that answers for the error still does not run when what was raised is a stop, because a stop is a stop. - An
xsl:on-emptyand anxsl:on-non-emptysay what the rest of the content made, which is what decides them.
A decision step stands where the branch is written, so following it shows you the test you are being told about and not the xsl:choose around it. It opens nothing: into, over, out and Inside work exactly as they did, and three xsl:whens read as three steps rather than as two silences.
Three things are deliberately not decisions. xsl:where-populated is a filter over what the content made rather than a branch, and what it kept is already what the step says it made. Nothing competes with an xsl:merge-action. And which template a pattern chose is a search over every rule of the mode for every item — a document of ten thousand nodes against twenty rules would be two hundred thousand decisions, and the recording would be a recording of pattern-matching rather than of your transformation. Inside tells you which template you are in.
Breakpoints
Because the run is already over, a breakpoint is a way of finding a step in a list rather than a way of stopping an engine — which gives you three things a debugger cannot. You set one where the instruction is: click in the stylesheet’s margin beside it, or press F9 on its line — a line with more than one instruction gets it on the outermost — or click the dot beside a step or beside a frame of Inside (beside the step you are at it is called Stop here). A dot is filled where a breakpoint stops and hollow where it is switched off; click again to take it away, and right-click a dot in the margin to open the Breakpoints tab. Then ◀● and ●▶, beside the other moves, go to the previous hit and the next one; backwards costs exactly what forwards costs.
- A breakpoint may carry a condition, written as XPath over the step itself:
variable[@name="qty"] > 100stops only where that variable is over a hundred,decision/@answer = "false"only where a test came out false,@instruction = "xsl:if"only on that kind of step. The variables in scope are already written down at every step, so this asks nothing of the transformation. - A step is a
<step>element with its instruction, module, place, depth, position and size as attributes, a<variable>per variable in scope (its value is the element’s content), a<context>for what the step stands on, a<decision>where the step is a branch, and a<produced>for what it made. It is read by the same XPath engine as the Query tab, so anything you can write there you can write here. - A breakpoint is kept on where the instruction stands in its module — which element of which element — and not on its line, so the edit you set it in order to make does not lose it. Run again and it is still on the instruction you put it on.
- Switch one off to keep it without stopping at it, and ✕ to remove it.
If no breakpoint is hit, you are told which of two things that means. Not hit in what was recorded is not the same as never hit: the recording stops where the engine says it stops, and nothing beyond that was ever written down. Looking is bounded too — a condition on an instruction that ran many thousands of times makes the search give up rather than keep you waiting, and it says so.
A long run, made readable
- Only what changed. At most steps no variable changes at all, so what you are shown is what this step changed; the whole set is one click away. (Measured over a run of two hundred rounds: two steps in three change nothing.)
- One variable through the whole run. Pick a name under Follow and you get every step at which its value became something else — bound, changed, gone out of scope — each one a click away. This is usually the question you actually have: *when did this become wrong?*
- Steps, beside it, is the whole run as a list. Narrow it by what the instruction is called, by which module it is in, or to the steps a breakpoint stops at; or fold it to a depth, so everything inside something you are not reading is left out. The numbers stay the run’s own numbers, so clicking a step takes you to that step — and takes the stylesheet’s editor with it, opening the module the instruction is written in where that is not the one you are looking at.
- Each row says what its instruction compares or walks, as you wrote it: the
testof anxsl:ifor anxsl:when, theselectof anxsl:for-eachor anxsl:apply-templates, thegroup-byof anxsl:for-each-group. Where an instruction has more than one, the telling one shows and the rest are there when you hover. Beside it stands what the step came to where the recording knows it — the answer a branch’s question got, which item of how many a loop is on — and the node it is standing on, which takes you to that node in the document.
Transformation pipelines
A pipeline (a .pipeline.json file) turns documents of one schema into documents of another: per place of the output it says where the content comes from — one per item of a repeating place of the input, a field, an XPath expression, or a block that filters, sorts, computes, chooses or copies — or deduplicates (keeping the first or the last of each set of equal keys) or groups (one per set, where current-group() is the set, so sum(current-group()/amount) adds it up) or aggregates (a count, a total, an average, the least, the most, the values joined, the first or the last of a place’s items, or of the group it stands in — a header’s count of the lines) or looks a value up in another input the pipeline names (a table of codes: the entries it looks in, the field it finds the code by, the field it gives; where no entry has the code, the block says what is done, as for a value that does not fit — Run a pipeline… asks which document to look in) or combines the items with the entries of another input (each item with the first entry whose field matches it; an item none matches kept, left out or a fault; the entries none matches written after the items or not; where both have a field, the side you prefer — the other inputs are drawn under the principal one, so an entry’s field is wired like any other; past 256 MiB of the other input the two are merged, and must then come in the order of their keys) or splits them two ways by a test (the items it is true for go on from its right-hand port, the rest from the port below it) or masks a value as a rule of a masking file says (Add a mask block: kept, its characters written as one, an invented name, an e-mail address with its domain kept, an IBAN of the same country whose check digits hold, a date moved by so many days, or each letter and digit replaced by another of its sort — which is also what is done with a value the rule does not fit; the seed chooses the values, and one value is masked the same wherever it is met) or holds XSLT as written (Add XSLT as written: what no other block says, in XSLT itself — the instructions that fill the place it is wired to, read in the item as an expression there is, and declarations such as a function or a template of its own mode, written once at the top of the stylesheet; each is edited in a small editor that marks, at its line, what the XSLT editor would say of it, and the prefixes it uses are given as prefix=namespace). A pipeline may write several outputs: each is drawn on the right, under the one before, and Run a pipeline… opens a tab for each, paired with its own schema. Schemantix checks it against the schemas it names, compiles it to one readable XSLT 3.0 stylesheet and runs it. You draw it in the pipeline editor, or write it as JSON in the text view — the two are one file.
- Open a pipeline as any data document. What is wrong with it — a place its schema no longer has, an expression that is not XPath, a field read outside the item it belongs to — is listed in Problems, each with the block or place it is about. It is checked again whenever you edit a schema it names, so taking a place out of a schema shows at once which pipelines wrote to it.
- Transformations › Run a pipeline… runs it over a document of the workspace: XML as it is, JSON or YAML through the XML mapping (the root as the outer key,
@for an attribute), a record file or CSV through its schema. The output opens in a tab of its own, checked against the output schema, written as that schema’s own document or as XML, JSON or YAML as you choose. Either end may be a JSON Schema, of any draft: its fields are drawn in the editor as the elements and attributes the XML mapping writes (each property of the root a document element,@namean attribute, an array one element per item), its input is checked as the JSON it is, and its output is written as the JSON the schema describes — a list where the schema lets a field repeat, a number,true/falseornullwhere its type says,12.50kept as12.50. Before the run the input is checked against its schema, read with your XML settings and at the present moment: under Strict — the setting XSLT and pipelines: validating the document first — an input that is not valid stops the run, under Lax it runs; either way what is wrong with it goes to the error output. A stylesheet a block of XSLT includes or imports, and the documents it reads, are found beside the pipeline:sheets/pick.xslwritten inflows/order.pipeline.jsonisflows/sheets/pick.xslof the workspace. - What a run was made of: where the dialog stays open after a run — a fault, a refusal — What this run was made of says the engine’s version and the SHA-256 of the pipeline file and of each schema it names, the figure
sha256sumgives for the file.schemantix pipeline run --provenancesays the same on the command line, and its--jsonalways carries it, so that a run in production can be shown to be of the pipeline that was tested, byte for byte. - A block can say what its value must be (
"as": "xs:date"). A value that is not is a fault, and the pipeline says what then happens: stop (nothing is written), skip (the item is left out and the rest written) or default (the block’sfallbackis written and a warning recorded). Every fault — of the input, the pipeline, the engine or the output — goes to the error output, which opens beside the output: code, severity, place, step and message key, plus the values the pipeline names undererrors.extension— and for a fault the pipeline meets, the record of a record file it was in (record), the route through the blocks (through) and a copy of the one item (item), so that a fault in a run over millions of records is found. - Export as XSLT (in the same dialog) opens the stylesheet for another processor, with each parameter’s default written into it. It reads and writes XML; a record file or JSON is converted first, with
schemantix convert— or, for a JSON Schema at either end, tick Export with a JSON adapter: the stylesheet then reads and writes that JSON itself, so another XSLT 3.0 processor runs it on the JSON and writes what the run here writes. Run it from the templatexsl:initial-template, with the parameterQ{urn:schemantix:pipeline}inputnaming the JSON document; its output is the JSON as text. An XSD end can be read or written as JSON too: with the adapter ticked, also tick The input as JSON or The output as JSON — the output is then written as the run writes an XSD’s output as JSON, a number ortrue/falsewhere its type says. - An exported stylesheet comes back as its pipeline. It carries the pipeline it was made from, at its end, in an element every processor passes over. Open the stylesheet and choose Transformations › Open the stylesheet as its pipeline: the pipeline opens beside it in its editor, blocks, wires and layout as they were. If the stylesheet was changed after it was exported, the pipeline still opens, and the status bar says that those changes are not in it. On the command line:
schemantix pipeline from-xslt letters.xsl --out letters.pipeline.json. - A stylesheet written by hand is read as a pipeline the same way. What it says the way a block does becomes that block — an
xsl:for-eachone per item, the tests on its path filters, itsxsl:sorta sort, anxsl:for-each-groupa group, anxsl:value-ofa field or a value, anxsl:choosea choice — and everything else is kept as it is written, in a block of XSLT as written standing where it stood. The schemas of its input and output are proposed from the paths it reads and the elements it writes, and opened beside the pipeline — every value in them a text, to be made to say what the documents hold — unless a schema of the workspace already has every place. The pipeline is then run beside the stylesheet on two documents of its input, and the status bar says whether it writes what the stylesheet writes. Where it did not, everything the top element holds is kept as written instead. On the command line,schemantix pipeline from-xslt hand.xslwrites the pipeline and the proposed schemas beside it (--input-schemaand--output-schemagive them instead) and lists what each line was read as. - Run into a file… — in the same dialog, where the application can write a file straight away (the desktop) — writes the output to a file you choose instead of opening it in a tab. An XML output goes into the file as it is made, an item at a time, so a large output never passes through the window; it is still checked against the output schema, as it is read back. A record file and a JSON Schema’s JSON or YAML go there a part at a time too, and an XSD’s output asked for as JSON or YAML, where it is valid. A run that stops part way leaves part of an output in the file, and the status bar says so.
- Or a file of your own, in the same dialog, runs the pipeline over a file you pick instead of a document of the workspace. It is not opened into the workspace: the run reads it as it goes, in blocks of 64 KiB — where the pipeline streams and the file is XML (in any encoding its declaration names), it is checked against its schema and run an item at a time, so a file larger than this tab could hold can still be run over; anywhere else it is read whole, within the limits this edition opens files to. On the command line,
--innames such a file. On the desktop Choose a file… picks it in the system’s dialog, and the desktop reads it itself — in pieces where the pipeline streams and it is XML — for Run and Run into a file… alike, so it never passes through the window.
The command line does the same: schemantix pipeline check, schemantix pipeline compile [--export [--json-adapter] [--json-ends in|out|both]] and schemantix pipeline run --in <file> [--out <file>] [--errors <file>] [--validate-source strict|lax] — with --out, an XML output is written as it is made — and schemantix pipeline places lists the two trees the editor draws.
The pipeline editor
A pipeline opens in its editor: the source schema’s tree on the left, the blocks in the middle, the target schema’s tree on the right. File › New › Transformation › Transformation pipeline makes one, from documents of one workspace schema to documents of another. The Pipeline tab under it shows the editor; Text shows the same file as JSON, which you may always edit — the editor follows it when you switch back.
- Draw a wire from a place of the source to a place of the target, or the other way round — it is the same wire, and the file says the same thing either way: per place of the target, where its content comes from. Drag from one port to the other, or click one port and then the other — or, from the keyboard, give a row the focus with Tab, choose it with Enter, and pick the other end under Fill from (a target place) or Wire to (a source place) beside the canvas. A wire onto a place that holds elements is one of these per item; onto a place that holds a value, the value of that field.
- A wire the pipeline cannot have is refused at the wire, drawn in red with its code and a sentence, and nothing is written. Most often that is the context rule: inside a place that is one per item, what is read must stand in that item, or be the one of it there is: the account’s name, the batch’s date in its one header, the account itself — but not the entries of another account, beside the item under something that repeats. Bind the place above it to that branch, or fill the field with an expression that reaches it. One per item may also fill a place that does not repeat, where what it takes its items from is there at most once: a letter’s detail written only where the account has one, through a filter — which may filter a place that does not repeat, giving it where its test holds.
- Blocks: select a place of the source to filter, sort or copy it; Add a block above the canvas offers every kind — a compute, choose or mask block, XSLT as written, and what works on the items of the repeating place you chose — and the block added is the one chosen. The XSLT tab beside the settings shows the stylesheet the pipeline compiles to, with Copy and Open as a stylesheet. Wire a block’s right-hand port onto the target, and a place or another block onto its left-hand port. Select a block to set it — a test, sort keys, a value, the type its value must be and what happens when it is not — each change written when you leave the field or press Enter; an expression field helps as you type (below). With nothing selected the inspector sets the pipeline itself: its title, its parameters, what happens when a value is not of its type and what a fault also says, the document element of each output, and its samples. Move a block by dragging it; Delete takes away a block or a wire you selected.
- Help in writing an expression: as you type, the field offers what may be written at the caret — the fields of the item the block works on first (a step at the start is read in the item), then the functions and axes of XPath — as the Query panel does: the arrows choose, Tab takes one, Escape closes the list. What is wrong with it is said under it as you type. Pick a field opens the item’s fields as a list you can search, and writes the one you click where the caret stands.
- Wizards ask in a few plain questions what the blocks that take most thought need, and add them as one step: Group with totals… (on a repeating place of the source: the key the items are grouped by, and for each total what is worked out and of what — a group, and an aggregate of each set for each total), Combine with another input… (the entries the items are joined to, the field of an entry and what of an item must match, what becomes of an item no entry matches and of the entries no item matches) and Add a lookup… (above the canvas: where it looks, the field it finds an entry by and the one it gives, the code it looks up). Each answer is offered from the schemas; wire the blocks to the target afterwards.
- Select a place of the target to see what fills it, to fill it with an XPath expression (Fill with this value), or to take its map away.
- Every gesture is one step to undo and redo, with the arrows in the toolbar. A gesture is checked by the same checker the Problems panel shows, before anything is written.
- A long tree — a copybook of two thousand fields — opens folded below its first level; the arrow on a row folds or unfolds it, and a wire to a folded place is drawn to the row that shows it.
- XSLT, beside the settings, shows the stylesheet the pipeline compiles to, a moment after each change, read-only — the lines the selected block or target place wrote marked. The trees remember how you folded them. The bar above the canvas says in a few words what this engine does with the input — Can run a part at a time or Needs its whole input; point at it, or open XSLT, for both verdicts — by the standard (XSLT 3.0’s rules, judged on what was written) and in this engine for this input — each with the reason where it does not stream. A pipeline that has an error compiles to nothing until it is mended.
- A schema too large to be shown whole — HL7’s FHIR schema, whose every element has extensions of fifty kinds — shows the first level, the way to each place the pipeline uses and what stands beside it; an element whose content is not shown yet has an arrow that opens it. The canvas fits both trees side by side to its width, as far as a row can still be read, and keeps doing so as the window or the panel changes until you move or zoom it; the fit button fits it again. The panel at the right folds away with the arrow at the end of its tabs — on a window narrower than 1280 px it starts folded — and opens again when you choose a row or a block. A pipeline has two tabs below it, Pipeline and Text: no diagram or grid of its JSON, which would show the file rather than the work; a test file has its text alone. Over the text of either it says what the file is and what it tests — Test file of policy.xsd — where a document offers the schema it is checked against: the application checks its own files by their own rules.
- One repeating place filled from several sources in turn — a letter for the date, then one per account, then a closing letter; a patient’s first identifier from one field and the second from another: the + on a repeating place of the output splits it into runs, each a row of its own with its number (*letter [1]*, *letter [2]*), filled from a source of its own and written in the order of their numbers. What filled the place goes to its first run; the + on a run adds one after the last. In the file a run is the place with its number after it,
out:#/elements/letters/sequence/0[2], and what stands in it is named after that. - Preview, the third tab, runs the pipeline over one of its samples or a document of the workspace — nothing is opened — and shows the output as a tree. Click a value to read its route: the items it was written for, the blocks they passed, and where the value came from — a field of the source, an expression, or a block with what that block gave this very item. Select a block on the canvas to see what it gave each item. A sample with a seed is generated from the input’s schema, the same document each time.
- Documentation: with a pipeline in the active tab, Documentation › Pipeline documentation saves one page about it — as HTML, or as Markdown for a repository that shows it — for someone who will never open the tool: what it reads and writes and against which schemas, its parameters, what happens where a value does not fit, each step with a sentence saying what it does and the expressions as written, and where each part of the output comes from.
schemantix pipeline documentwrites the same page (with--markdown, the Markdown). The page lists the workspace’s test files about the pipeline, with the latest run (see “Declared tests”). - When a schema changes under a pipeline: the file keeps what each place it names is called (
names, written with every gesture), so a place its schema no longer has — a field moved or the schema reordered — is found again by its names: the Problems panel says where it is now, and Point to the new places above the canvas points the pipeline there, one step to undo.schemantix pipeline check --fixdoes the same on the command line. A place the output’s schema requires and nothing fills, under a part that is written, is a warning: the output would not be valid.
Keyboard shortcuts
| Ctrl+F | Go to the search field (text or nodes), also from within the text |
|---|---|
| Ctrl+K | Go to the search field, too |
| Ctrl+H | In the text: find and replace |
| Ctrl+S | Download the document shown (a schema with the documents it needs) |
| Enter / Shift+Enter | In the search field: next / previous match |
| Ctrl+Space | Text editor and data documents: show suggestions |
| Tab / Shift+Tab | Text editor: indent / outdent |
| Escape, Tab | Text editor: move on to the next control |
| Escape | Close the dialog or menu that is open |
| ↓ / ↑, Home / End | In an open menu: the next or previous entry, the first or the last |
| ← / → | In an open menu: the menu beside it in the toolbar |
| F3 / Shift+F3 | Text editor: next / previous match of the search |
| F12 | Text editor: go to the definition the reference at the cursor points at |
| Ctrl/Cmd + click | Text editor: go to the definition of the reference you click on |
| F2 | Diagram: rename the selected node on its card (Enter keeps, Escape cancels) |
| Delete / Backspace | Diagram: remove the selected node, or the whole selection, from the schema |
| Ctrl+C / Ctrl+X / Ctrl+V | Diagram: copy or cut the selected node — or the whole selection — as schema text, and paste it under the node selected |
| Ctrl+Z | Undo — in the diagram the last diagram edit, in the text or a field your typing |
| Ctrl+Y / Ctrl+Shift+Z | Redo |
| Ctrl/Cmd + click | Diagram: add a node to the selection, or take it out again |
| Shift + click | Diagram: extend the selection through the layer to this node |
| Shift + drag | Diagram: draw a rubber band over the cards |
| Escape | Close a dialog, menu, popup or suggestion list; clear the selection or the search field |
On a Mac, use Cmd instead of Ctrl — except for Ctrl+Space (Option+I also works).
Your data and privacy
Schemantix works entirely in your browser. Documents are read, checked and generated on your own computer and are not sent anywhere. The only time the application goes on the internet for you is when you click Load for a referenced web document.
- The documents you are working on (a working copy, with the tab you had open among them) and your recent files are kept in this browser’s storage, so an accidentally closed tab loses nothing. They stay on this computer.
- Preferences — language, theme, panel sizes, Patience, which lists on the left are folded away, which diagram cards are open and which view each document was shown in — are kept in the browser too.
- Clearing the site data in your browser removes all of this. Download what you want to keep.
Editions and the licence
The browser edition is free and needs no licence. The desktop edition and the command line are paid for, under a signed licence file that names who it is for, the organisation, the last day it is valid, the number of users and of threads, and the editions it covers. It is checked on your own computer, without a network, so it works inside a closed network too. Help › Licence… shows what the licence says, or — where none is loaded — that Schemantix runs as the free browser edition. Nothing is ever locked: without a licence in force (none, one that has expired, one for another edition) everything works as it does in the browser.
On the command line, schemantix licence says which licence is loaded, and schemantix licence install <file> checks one and puts it in your own settings folder (%APPDATA%\Schemantix on Windows, ~/.config/schemantix elsewhere), where every later run finds it. --licence <file> or the variable SCHEMANTIX_LICENCE names another. A licence that is changed after it was signed — even only its spacing — is no longer accepted. A command that works through many files — derive --all, guess-encoding, and validate, convert and transform given a folder in place of a document — shares them out over as many threads as --threads <n> asks, and says what each found in the same order whatever the number: as many as the licence names, and one without a licence (the work is then done on one thread, with a note saying so). A folder is taken by itself, its subfolders too with --recursive, and only the files --include "*.xml" names where you say so; convert and transform write each file into the folder --out names, mirroring the subfolders (in/2026/a.xml becomes out/2026/a.json), and a link in the folder is passed over, never followed.
A document from a pipe: where a command reads a data document — validate, transform, query, convert, anonymise, lay-out, propose-record, propose-schema, guess-encoding, pipeline run --in, edit --sample — and the schema document, diagram and operations read, - names standard input, so a file kept somewhere Schemantix has no connector for is read without saving it first: aws s3 cp s3://bucket/order.xml - | schemantix validate - --schema order.xsd. It is read as a file is — by its byte-order mark, its XML declaration, or the code page its record schema names — and a pipeline’s XML input in pieces, as a file of it is. It has no name and no folder: what is said about it calls it -, and what it refers to is looked for in the folder --folder names, or else the current one. A pipe can be read once, so - is accepted once per command, and not for a schema named with --schema, a stylesheet or a document named with --with. Where the result goes to the screen, nothing else does — notes and findings beside it go to the error stream — so schemantix convert - --to json | jq reads JSON.
Large files are read a part at a time on the command line, with the same findings at the same places as a reading of the whole file. schemantix validate <file> --schema <schema> (or - from a pipe) checks a record file a record at a time — gigabytes from a mainframe in a few megabytes — and an XML document against its XSD, or a JSON or YAML document against its JSON Schema, a part at a time. schemantix convert writes record files, JSON, YAML and XML into one another the same way, schemantix anonymise replaces a large document a part at a time, each value from the seed and the value alone, so the same seed makes the same copy, and schemantix pipeline run reads a record file in pieces. Where something needs the whole file — a trailer test other than counts and sums, a JSON Schema keyword about the whole top value (enum, uniqueItems, oneOf…), YAML anchors, a document type declaration, Schematron — it is read whole, and the command says why. A check may do more work the larger the document is, so a large document is checked to its end; --max-steps <n> names another bound, 0 none. In the browser, Data › Check a file without opening it… does the same for a record file, an XML document or a JSON or YAML document: pick the schema and the file, and the findings are listed with their line and column. A file is still bounded by the size this edition opens; where a test needs the whole file, the dialog says which and offers to open it.