Validate XML
Validates XML against an XSD schema set and routes valid and invalid documents separately.
@lainstack/xml/validate · Data
How to use it
Section titled “How to use it”Validate XML checks one XML document against an XSD schema set. A valid document leaves by the valid port and an invalid one by the invalid port. It only reports a verdict and does not change the document.
Pass the document as text in xml, or as a file in xmlFile, for example from @lainstack/s3/read-object or an upload. Give the schema as inline schema text for a single file, or as schemaFile for one or more .xsd files or a .zip schema set.
Traps:
- An invalid document does not fail the step by default. It continues on the
invalidport witherrorCount,truncated,summaryanderrors(line, column, path, element, message). SetonInvalidtofailto fail the run with errorxml_invalidinstead. Wire both ports when you keep the default. errorslists at mostmaxErrorsentries (default 20, maximum 200).errorCountcounts all errors.truncatedis true when some are not listed.- Setting both
xmlandxmlFile, or bothschemaandschemaFile, fails the step, as does giving no schema. An empty document is an invalid verdict, not an error. - Inline
schemais at most 64,000 characters. Imports and includes resolve only to relative paths inside the supplied files. Nothing is fetched from the network. - With more than one .xsd file, set
schemaEntryto the main one. Do not mix a .zip with .xsd files. - Files must be UTF-8. The XML file is at most 8 MiB and the schema set at most 32 MiB.
- A broken schema set or an engine failure fails the step. It does not produce an invalid verdict.
Settings
Section titled “Settings”| Setting | Key | Type | Details |
|---|---|---|---|
| XML document | xml |
Text | The XML to validate. Type it or insert an upstream value. Leave empty to use an XML file. |
| XML file | xmlFile |
Value | Validate an XML file from an earlier step instead of XML text. |
| Schema | schema |
Text | Inline XSD for a single-file schema. For schemas that import or include other files, use Schema files instead. |
| Schema files | schemaFile |
Value | One .xsd file, several .xsd files, or a .zip of the whole schema set. Imports and includes resolve only to relative paths within those files; nothing is fetched from the network. |
| Main schema | schemaEntry |
Text | Path of the main .xsd: its path inside the .zip, or its file name. Not needed when there is only one .xsd. |
| When invalid | onInvalid |
One of Continue on the Invalid branch, Fail the run |
Continue on the Invalid branch with the errors, or fail the run. Defaults to the Invalid branch. Default route. |
| Maximum errors listed | maxErrors |
Number | How many errors to list (1 to 200). All errors are counted. Defaults to 20. |
Outputs
Section titled “Outputs”| Output | Path | Type |
|---|---|---|
| Valid | valid |
Yes or no |
| Error count | errorCount |
Number |
| More errors than listed | truncated |
Yes or no |
| Summary | summary |
Text |
| Errors | errors |
List |
| Exit | Port | Notes |
|---|---|---|
| Valid | valid |
|
| Invalid | invalid |