For the complete documentation index, see llms.txt. This page is also available as Markdown.

Validating XML

The Framework includes two ways to validate both of two forms of XML

CsvPath Framework supports XML as:

  • Single XML document per file

  • Inline XML embedded within a CSV or JSONL file (flattened into a string within a header)

When you apply XSD or XPath (the xsd() and xpath(), respectively) to whole documents, you only do one pass. It wouldn't make sense to iterate line by line so you just run one line. The best way to set that up is to explicitly do:

  • A one-line scanning instruction like [3]

  • An all lines scanning instruction ([*]) combined with stop() as the last line of the csvpath driver

The second approach is more robust to skipped blank lines. E.g. if you do [0] but have one or more skipped blank lines you won't get your single pass through the doc because the scanning instruction hits a line that doesn't trigger matching evaluation. For this reason it much better to use [*] with stop() as the last line of the csvpath.

When you validate XML you have three choices:

(The latter meaning within the Framework as separate complementary approaches. You can also apply certain XPath statements within an XSD, if you prefer that style).

XSDs are relatively complex, but well known and with good tools. (Shoutout to XMLSpy for great XSD visualization).

Using XPath to validate XML is probably a bit less common. The standard for XPath validation is Schematron. CsvPath Framework doesn't support Schematron. However, CsvPath Validation Language was actually inspired, in part, by Schematron, and can do essentially the same thing, but with cleaner, simpler syntax. We love using XPath to validate XML and we think, naturally, that CsvPath Validation Language is a more delightful way to do it. We may be biased.

Last updated