Schematron 1.0.0

dotnet add package Schematron --version 1.0.0
                    
NuGet\Install-Package Schematron -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Schematron" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Schematron" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Schematron" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Schematron --version 1.0.0
                    
#r "nuget: Schematron, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Schematron@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Schematron&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Schematron&version=1.0.0
                    
Install as a Cake Tool

EULA OSS GitHub

A .NET implementation of Schematron for validating XML with standalone .sch schemas or Schematron rules embedded in W3C XML Schema. The library supports both the current ISO Schematron namespace and the legacy ASCC namespace, with a compact public API centered on Validator and Schema.

Installation

dotnet add package Schematron

The package targets netstandard2.0 and net8.0.

Usage

The package exposes two primary entry points:

  • Validator loads Schematron and XML Schema definitions and validates XML documents.
  • Schema loads and inspects Schematron documents programmatically.

One-shot validation with a standalone Schematron schema

using Schematron;

var validator = new Validator();
validator.AddSchema("order.sch");

try
{
    validator.Validate("order.xml");
    Console.WriteLine("Document is valid.");
}
catch (ValidationException ex)
{
    Console.WriteLine(ex.Message);
}

Validate returns the loaded IXPathNavigable document on success and throws ValidationException when XML Schema or Schematron validation fails.

Validating XSD plus embedded Schematron

When the schema is a W3C XML Schema document with embedded Schematron, Validator runs both validations in one pass:

using Schematron;

var validator = new Validator(OutputFormatting.XML);

// Use the overload with the target namespace when the XSD imports or includes other schemas.
validator.AddSchema("http://example.com/po-schematron", "po-schema.xsd");

try
{
    validator.Validate("purchase-order.xml");
}
catch (ValidationException ex)
{
    Console.WriteLine(ex.Message); // XML formatted output
}

Schematron-only validation for in-memory XML

If you already have an IXPathNavigable, use ValidateSchematron to skip XML Schema validation and evaluate only the loaded Schematron rules:

using System.Xml.XPath;
using Schematron;

var validator = new Validator();
validator.AddSchema("rules.sch");

var document = new XPathDocument("order.xml");
validator.ValidateSchematron(document);

Selecting the phase, formatter, and return type

Validator lets you control the active phase, output format, and result type:

using Schematron;
using Schematron.Formatters;

var validator = new Validator(OutputFormatting.XML, NavigableType.XmlDocument)
{
    Phase = "paymentInfo",
    Formatter = new XmlFormatter(),
};

validator.AddSchema("purchase-order.sch");
var result = validator.Validate("purchase-order.xml");

Use Phase.All (#ALL) to evaluate every pattern regardless of phase activation.

Loading and inspecting a schema

Use Schema directly when you want to inspect a Schematron document without validating an instance document yet:

using Schematron;

var schema = new Schema();
schema.Load("rules.sch");

Console.WriteLine(schema.Title);
Console.WriteLine(schema.SchematronEdition);
Console.WriteLine(schema.DefaultPhase);
Console.WriteLine(schema.IsLibrary);
Console.WriteLine(schema.Patterns.Count);
Console.WriteLine(schema.Lets.Contains("maxAge"));

This is useful for tooling, analyzers, test helpers, or apps that need to inspect declared phases, patterns, diagnostics, parameters, and let bindings.

Core API

Schematron keeps the public surface intentionally small:

  • Validator is the main entry point for loading schemas and validating XML.
  • Schema loads and inspects Schematron documents programmatically.
  • OutputFormatting selects the built-in output style: Default/Log, Simple, Boolean, or XML.
  • Validator.Phase, Validator.Formatter, and Validator.ReturnType let you choose the active phase, custom output formatter, and returned document type.
  • BadSchemaException signals invalid schema input, while ValidationException signals XML or Schematron validation failures.

Supported features

The package currently supports the main scenarios expected for a v1 release, including:

  • Standalone .sch schemas and Schematron embedded in W3C XML Schema
  • ISO Schematron namespace (http://purl.oclc.org/dsdl/schematron) and legacy ASCC namespace compatibility
  • ISO Schematron 2025 features such as <library>, phase @when, rule @visit-each, rule flags, and schema parameters
  • Schema-, pattern-, and rule-level let bindings
  • Diagnostics, severity metadata, abstract patterns/rules, and groups

Open Source Maintenance Fee

To ensure the long-term sustainability of this project, users of this package who generate revenue must pay an Open Source Maintenance Fee. While the source code is freely available under the terms of the License, this package and other aspects of the project require adherence to the Maintenance Fee.

To pay the Maintenance Fee, become a Sponsor at the proper OSMF tier. A single fee covers all of Devlooped packages.

Sponsors

Clarius Org MFB Technologies, Inc. Khamza Davletov SandRock DRIVE.NET, Inc. Keith Pickford Thomas Bolon Kori Francis Reuben Swartz Jacob Foshee alternate text is missing from this package README image Eric Johnson Jonathan Ken Bonny Simon Cropp agileworks-eu Zheyu Shen Vezel ChilliCream 4OTC domischell Adrian Alonso torutek mccaffers Seika Logiciel Andrew Grant eska-gmbh

Sponsor this project

Learn more about GitHub Sponsors

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 135 4/29/2026
1.0.0-beta 96 4/29/2026
0.6.18 15,917 6/10/2016
0.6.17 1,490 6/5/2016
0.6.13 1,475 6/3/2016
0.6.12 1,524 4/5/2016
0.6.11 1,596 12/21/2015
0.6.4 1,470 12/14/2015
0.6.3 1,489 12/14/2015