EricksonLopez.Xml.Validation Overview
L3StableNuGet: v1.0.0Local HEAD: v2.0.0AOT: Full
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) enforceDtdProcessing.ProhibitandXmlResolver = null. - Exception-free
Result<bool>validation: Schema violations, malformed XML, and unregistered namespaces returnEricksonLopez.Result.Result<bool>failures instead of throwingXmlSchemaException. - Global root element & boundary isolation (
ADR-017):XmlSchemaCachepre-indexes global root elements forO(1)declaration lookup while keeping mutableXmlSchemaSetinstances isolated behind internalIXmlSchemaSetProvider.
Rendering diagram…
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)"]
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 Roster & Native AOT Status (1 / 1 Published)
Section titled “Package Roster & Native AOT Status (1 / 1 Published)”| 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 BValidateFromString: 3,055.291 ns / 75,662 BValidateFromSpan: 3,173.613 ns / 108,593 B (Note: whileReadOnlySpan<byte>avoids copying input bytes into an intermediate string/stream, .NET BCLXmlReaderinternal buffers still allocate ~108 KB on the benchmark fixture.)ValidateFromStream: 3,222.165 ns / 108,514 B