Skip to content

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.

EricksonLopez.Xml.Validation Overview

EricksonLopez.Xml.Validation (1.0.0 on NuGet, L3, 257 downloads — note there is no root EricksonLopez.Xml NuGet package) delivers Anti-XXE XSD schema compilation, thread-safe schema caching, and multi-modal Result<bool> document validation across string, Stream, ReadOnlySpan<byte>, and ValidateAsync.

  • Mandatory Anti-XXE hardening: Both schema compilation (XmlSchemaCache) and document readers (XmlSchemaValidator) enforce DtdProcessing.Prohibit and XmlResolver = null.
  • Exception-free Result<bool> validation: Schema violations, malformed XML, and unregistered namespaces return EricksonLopez.Result.Result<bool> failures instead of throwing XmlSchemaException.
  • Global root element & boundary isolation (ADR-017): XmlSchemaCache pre-indexes global root elements for O(1) declaration lookup while keeping mutable XmlSchemaSet instances isolated behind internal IXmlSchemaSetProvider.
flowchart LR
XSD["XSD Schemas"] --> Cache["IXmlSchemaCache (DtdProcessing.Prohibit, XmlResolver=null)"]
XML["XML (string / ReadOnlySpan<byte> / Stream)"] --> Val["IXmlSchemaValidator"]
Cache --> Val
Val --> Res["Result<bool> (Success / SchemaViolation / XmlMalformed)"]
Anti-XXE Schema Cache and Multi-Modal Validator FlowXmlSchemaCache compiles and indexes XSD schemas with DtdProcessing.Prohibit, then XmlSchemaValidator streams string, ReadOnlySpan<byte>, or Stream payloads to produce Result<bool>.
View accessible text summary and structure

XmlSchemaCache compiles and indexes XSD schemas with DtdProcessing.Prohibit, then XmlSchemaValidator streams string, ReadOnlySpan<byte>, or Stream payloads to produce Result<bool>.

flowchart LR
XSD["XSD Schemas"] --> Cache["IXmlSchemaCache (DtdProcessing.Prohibit, XmlResolver=null)"]
XML["XML (string / ReadOnlySpan<byte> / Stream)"] --> Val["IXmlSchemaValidator"]
Cache --> Val
Val --> Res["Result<bool> (Success / SchemaViolation / XmlMalformed)"]
Package NuGet (1.0.0) Local HEAD AOT Status TFMs Role
EricksonLopez.Xml.Validation Published (257 dl) 2.0.0 Full net8.0;net9.0;net10.0 IXmlSchemaCache, XmlSchemaCache, IXmlSchemaValidator, XmlSchemaValidator, AddXmlValidation

Measured directly from BenchmarkDotNet.Artifacts (4 / 4 measured rows in XmlValidationBenchmarks, Job=ShortRun, IterationCount=3, WarmupCount=3, .NET 10.0.11 X64 RyuJIT x86-64-v4, AMD Ryzen 7 9800X3D; no NativeAOT reports):

  • CacheLookupContainsSchema: 6.265 ns / 0 B
  • ValidateFromString: 3,055.291 ns / 75,662 B
  • ValidateFromSpan: 3,173.613 ns / 108,593 B (Note: while ReadOnlySpan<byte> avoids copying input bytes into an intermediate string/stream, .NET BCL XmlReader internal buffers still allocate ~108 KB on the benchmark fixture.)
  • ValidateFromStream: 3,222.165 ns / 108,514 B