Format-agnostic, span-based .NET libraries for reading, validating, and querying XML-based schema formats such as XSD and Schematron. The solution provides an XML reader and document model, an XPath evaluator, a Schematron validator, and an XSD validator behind one validator contract, for developers who need schema validation in managed code.
Note
The solution is in development and no package has been released yet. The conformance rates below describe the state of the main branch.
The packages form layers; each package depends only on the packages to its left:
NetEvolve.Schemas <- DependencyInjection <- Xml <- XPath <- { Schematron, Xsd }- Core:
NetEvolve.Schemasdefines the validator contract, the result model, validation limits, and external resource resolvers. - XML and XPath:
NetEvolve.Schemas.Xmlreads documents andNetEvolve.Schemas.XPathevaluates expressions over them. - Formats:
NetEvolve.Schemas.SchematronandNetEvolve.Schemas.Xsdeach add aSchemaValidator.For<Format>()entry point, a C# 14 extension member that returns a fluent builder. - Integration:
NetEvolve.Schemas.DependencyInjectionis the generic registration core (AddSchemaValidator,AddKeyedSchemaValidator) forMicrosoft.Extensions.DependencyInjectionand references no format package. Each format package (Xmlfor DTD,Xsd,Schematron) carries its ownAdd<Format>ValidatorandAddKeyed<Format>Validatorextensions in the namespaceMicrosoft.Extensions.DependencyInjection, so referencing one format brings no other format's assembly.
All packages target netstandard2.0, net10.0, and net11.0. Beyond the layers above, every package has one runtime dependency, NetEvolve.Arguments, and the netstandard2.0 builds add three Microsoft polyfill packages.
| Package | Purpose | Depends on | Target frameworks | Status |
|---|---|---|---|---|
NetEvolve.Schemas |
Validator contract, result model, limits, and resolvers | none | netstandard2.0, net10.0, net11.0 |
Not yet released |
NetEvolve.Schemas.DependencyInjection |
Generic dependency injection registration core | NetEvolve.Schemas, Microsoft.Extensions.DependencyInjection.Abstractions |
netstandard2.0, net10.0, net11.0 |
Not yet released |
NetEvolve.Schemas.Xml |
XML reader, document model, and DTD validation, with the DTD registration extensions | NetEvolve.Schemas, NetEvolve.Schemas.DependencyInjection, Microsoft.Extensions.DependencyInjection.Abstractions |
netstandard2.0, net10.0, net11.0 |
Not yet released |
NetEvolve.Schemas.XPath |
XPath evaluation (XPath 2.0; XPath 3.0 and 3.1 partial) | NetEvolve.Schemas.Xml |
netstandard2.0, net10.0, net11.0 |
Not yet released |
NetEvolve.Schemas.Schematron |
Schematron validation with SVRL output, with the Schematron registration extensions | NetEvolve.Schemas.XPath, NetEvolve.Schemas.DependencyInjection, Microsoft.Extensions.DependencyInjection.Abstractions |
netstandard2.0, net10.0, net11.0 |
Not yet released |
NetEvolve.Schemas.Xsd |
XSD validation, with the XSD registration extensions | NetEvolve.Schemas.XPath, NetEvolve.Schemas.DependencyInjection, Microsoft.Extensions.DependencyInjection.Abstractions |
netstandard2.0, net10.0, net11.0 |
Not yet released, partial |
The target frameworks are set once in src/Directory.Build.props. Only NetEvolve.Schemas is packable today; the other projects become packable when their package lands (Directory.Build.props). The XPath and XSD packages have no package readme yet.
- tests/ - one
Tests.Unitproject per package,Tests.Integrationprojects for XML, XPath, XSD, and Schematron, and the architecture, public API, packaging, and legacy compiler checks. - tests/NetEvolve.Schemas.Conformance - the shared harness that fetches the pinned conformance suites, compares results with the known-failure baselines, and reports the rates.
- benchmarks/ - benchmarks of the hot paths.
- Span-based input - validate a
Stream,ReadOnlySpan<byte>,ReadOnlySpan<char>,ReadOnlySequence<byte>, orReadOnlySequence<char>. - One validator contract - every format returns an immutable, thread-safe
ISchemaValidatorwith the same result model, issue codes, and locations. - Schematron validation - ISO/IEC 19757-3:2025 with phases, parameters, includes, and SVRL output.
- XML reading - an XML 1.0 (Fifth Edition) reader with namespaces, optional DTD processing, and DTD validation.
- XPath evaluation - XPath 2.0; XPath 3.0 and 3.1 are partial.
- XSD validation - XSD 1.0 schema compilation and instance validation; XSD 1.1 is partial.
- Secure defaults - bounded input, depth, and entity expansion, no document type declaration, and no external access unless a resolver is set.
- Dependency injection - plain and keyed registration of validators as lazily built singletons.
- .NET SDK 11.0 or higher (the solution builds the
net11.0target; the SDK also buildsnet10.0andnetstandard2.0) - Git for version control
- Visual Studio or Visual Studio Code (recommended)
- A compiler with C# 14 for the
SchemaValidator.For<Format>()extension members; older compilers call the static extension classes directly (see the package readmes)
No package has been released yet, so the packages are built from source:
-
Clone the repository:
git clone https://github.com/dailydevops/schemas.git cd schemas -
Restore dependencies:
dotnet restore
-
Build the solution:
dotnet build --configuration Release
-
Run tests to verify installation (the conformance suites are fetched on first use, so this needs network access):
dotnet test --solution Schemas.slnx --configuration Release
The Schematron entry point compiles a schema into an immutable, thread-safe validator. The sample runs in an async method that has a CancellationToken cancellationToken. A failed assert is an issue with severity Error: here result.IsValid is false, and the single issue carries the code NES3400 and the message The total 150 exceeds 100. See the Schematron package readme for phases, parameters, includes, and SVRL output.
const string schema = """
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<sch:pattern id="totals">
<sch:rule id="order" context="order">
<sch:assert id="total-limit" test="number(@total) le 100">The total <sch:value-of select="@total"/> exceeds 100.</sch:assert>
<sch:report test="number(@total) = 0">The total is zero.</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
""";
var validator = await SchemaValidator.ForSchematron(schema).BuildAsync(cancellationToken);
var result = await validator.ValidateAsync(
"""<order total="150"/>""".AsMemory(),
"file:///orders/1.xml",
cancellationToken
);dotnet build# Run all tests
dotnet test --solution Schemas.slnx --configuration Release
# Run one test project on one target framework
dotnet test --project tests/NetEvolve.Schemas.Tests.Unit --configuration Release --framework net10.0The test projects run on three legs: net9.0 (runs the netstandard2.0 build of the libraries), net10.0, and net11.0. Every behavior change starts with a failing TUnit test; see the development workflow.
# Format code using CSharpier
csharpier format .src/ # Production code, one folder per package
├── NetEvolve.Schemas/
├── NetEvolve.Schemas.Xml/
├── NetEvolve.Schemas.XPath/
├── NetEvolve.Schemas.Schematron/
├── NetEvolve.Schemas.Xsd/
├── NetEvolve.Schemas.DependencyInjection/
└── Shared/ # Polyfills shared by the netstandard2.0 builds
tests/ # Test projects and the conformance harness
├── conformance/ # Suite manifests (suites/) and known-failure baselines (baselines/)
└── NetEvolve.Schemas.*
benchmarks/ # Benchmarks
docs/ # Development workflow and XSD deviations
specs/ # Specification notes
templates/ # Documentation and file templates- Layered packages: the dependency direction is fixed (see Overview).
- Format-agnostic core: format packages contribute a builder and a validator; the contract, result model, limits, and resolvers live in
NetEvolve.Schemas. - Immutable validators: a builder is not thread-safe, the validator it builds is.
- Deny by default: external resources are refused unless a resolver is configured (see Security Defaults).
- Argument validation: guards use
NetEvolve.Arguments, which ships as a runtime dependency of every package.
Each rate is passed / (passed + failed), truncated to one decimal. Skipped and excluded cases are not counted. A failure is either fixed or listed in a committed known-failure baseline under tests/conformance/baselines/; a failure outside the baseline and a baselined case that passes both fail the run. The suites are pinned by checksum in tests/conformance/suites/ and are never committed.
The rates were measured on main at commit a2d4119 with net10.0. The Conformance workflow (.github/workflows/conformance.yml) publishes the same rate rows in its job summary: the runners append them to the file named by the GITHUB_STEP_SUMMARY environment variable, so set that variable to a file path to get the rows locally. The rows below that name a test project and a filter come from that summary: run dotnet test --project tests/<project> --configuration Release --framework net10.0 --treenode-filter "<filter>".
| Suite | Package | Applicable | Passed | Rate | Measured with |
|---|---|---|---|---|---|
| W3C XML Conformance Test Suite (xmlconf), non-validating reader | NetEvolve.Schemas.Xml |
2,001 | 1,980 | 98.9% | Xml package readme; 21 baselined cases in tests/conformance/baselines/xmlconf |
| xmlconf, DTD validation | NetEvolve.Schemas.Xml |
943 | 931 | 98.7% | NetEvolve.Schemas.Xml.Tests.Integration, filter /*/*/*Xml*Conf*SuiteTests/*; 12 baselined, 14 skipped |
| W3C QT3 test suite, XPath 2.0 selection | NetEvolve.Schemas.XPath |
14,550 | 14,330 | 98.4% | NetEvolve.Schemas.XPath.Tests.Integration, filter /*/*Conformance*/*/*; 220 baselined cases in tests/conformance/baselines/qt3, 738 skipped |
| W3C XML Schema Test Suite (XSTS) 1.0, schema tests | NetEvolve.Schemas.Xsd |
14,357 | 14,235 | 99.1% | NetEvolve.Schemas.Xsd.Tests.Integration, filter /*/*Conformance*/*/*; 122 baselined cases |
| XSTS 1.0, instance tests | NetEvolve.Schemas.Xsd |
24,914 | 24,017 | 96.3% | same run; 897 baselined cases |
| XSTS 1.1, schema and instance tests | NetEvolve.Schemas.Xsd |
41,389 | 0 | 0.0% | derived from the same run: the row for all of XSTS (80,660 applicable, 38,252 passed, 47.4%) minus both XSTS 1.0 rows |
Schematron conformance suite 2.0, bindings xslt-1 and xslt-2 |
NetEvolve.Schemas.Schematron |
84 | 55 | 65.4% | NetEvolve.Schemas.Schematron.Tests.Integration, filter /*/*Conformance*/*/*; 29 baselined cases in tests/conformance/baselines/schematron-conformance, 3 excluded |
| EN 16931 (CEN) validation artefacts 1.3.17, golden tests | NetEvolve.Schemas.Schematron |
1,174 | 1,174 | 100.0% | NetEvolve.Schemas.Schematron.Tests.Integration, filter /*/*/En16931GoldenTests/*; no baselined cases |
| EN 16931 (CEN) 1.3.17, EDIFACT binding, ISO 20625 XML examples | NetEvolve.Schemas.Schematron |
9 | 9 | 100.0% | NetEvolve.Schemas.Schematron.Tests.Integration, filter /*/*/En16931ExtendedGoldenTests/*; no baselined cases |
EN 16931 (CEN) 1.3.17, UBL rule set, complete invoices of test/testfiles |
NetEvolve.Schemas.Schematron |
29 | 29 | 100.0% | same run; no baselined cases |
Not yet reported:
- QT3 XPath 3.0 and 3.1. The tiers run in
Qt3Xp3ConformanceTestsagainst the baselinestests/conformance/baselines/qt3-xp30(2,903 known-failure entries) andqt3-xp31(1,477 entries), but no rate is published yet, and the QT3 runner has no XPath 3.0 mode. A case that needs XPath 3.x syntax or functions is a known failure until the XPath package supports it (#328, #353, #355, #356). - Further Schematron rule sets. Manifests for more rule sets are pinned in
tests/conformance/suites/; no rate is published for them.
The table is updated by hand and can lag behind CI between releases.
- Bounded input:
ValidationLimits.Defaultcaps input size, element depth, entity expansion, and resolved resources. Every limit is finite and can be changed per builder withWithLimits. The defaults are provisional until they are benchmarked. - No document type declaration by default: the XML reader rejects a document type declaration (
XML2001) unless DTD processing is switched on, and it never opens an external resource on its own. The Schematron validator rejects a document type declaration in a schema or a document. - External resources are deny by default: unless a resolver is configured, every request for an external resource is refused (
NES0100).SandboxedFileSystemResourceResolverservesfileURIs below one root directory and refuses everything else.
See the core and XML package readmes for the details.
- No release yet. Names and APIs are provisional until the first release.
- XPath 3.0 and 3.1 evaluation is partial. Syntax with version gating (#328), function items and dynamic calls (#353),
let, simple map, and string concatenation (#355), and maps, arrays, lookup, and arrow (#356) are open. XPath 2.0 is the supported level. - XSD 1.1 is partial. The XSD 1.1 features are not wired into compilation and validation (#360), except the assertions on complex types, which run in the default builder (#318). None of the XSTS 1.1 cases passes yet.
- XSD 1.0 instance validation is incomplete. 60.2% of the XSTS 1.0 instance cases pass; the rest are baselined.
- XML 1.1 is not supported. The reader accepts XML 1.0 only and cannot switch namespace processing off.
- Schematron supports a subset of XSLT.
xsl:template,xsl:apply-templates,xsl:call-template,xsl:iterate,xsl:try, and other elements are rejected withNES3204, and stylesheet functions and keys are not callable from a rule yet. The pattern attributedocumentsand the rule attributevisit-eachare accepted and ignored. See the Schematron package readme for the full list with issue links. - Compilers older than C# 14 call the static extension classes directly instead of
SchemaValidator.For<Format>().
We welcome contributions from the community! Please read our Contributing Guidelines before submitting a pull request.
Key points:
- Follow the Conventional Commits format for commit messages
- Write the failing test first; see the development workflow
- Follow existing code style and conventions
- Update documentation as needed
This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to info@daily-devops.net.
- Contributing Guidelines - How to contribute to this project
- Development workflow - Test-first workflow and bug handling
- XSD deviations - Where the XSD validator deviates from the standard
- Conformance suites - How the suites are pinned and fetched
- Code of Conduct - Community standards and expectations
- License - Project licensing information
This project uses GitVersion for automated semantic versioning based on Git history and Conventional Commits. Version numbers are automatically calculated during the build process.
- Issues: Report bugs or request features on GitHub Issues
- Documentation: Read the full documentation in this repository
This project is licensed under the MIT License - see the LICENSE file for details.
Note
Made with ❤️ by the NetEvolve Team Visit us at https://www.daily-devops.net for more information about our services and solutions.