Search code examples
javac#xmlxsdxsd-1.1

XSD 1.1 validation for both Java and .NET C#?


I have an XSD with schema version 1.1, and I want to validate an XML against it programmatically via .NET and Java.

In .NET I use XmlSchemaSet class to validate XML against XSD, but it throws the following exception:

`System.Xml.Schema.XmlSchemaException: The 'http://www.w3.org/2001/XMLSchema:assert' element is not supported in this context.

So I guess .NET still supports XSD 1.0 and doesn't support XSD 1.1 ?


Solution

  • Correct, .NET supports XSD 1.0, not XSD 1.1. You can use Xerces to validate XML against XSD 1.1 in Java, but there are no free libraries that support XSD 1.1 on .NET.

    To validate XML using XSD 1.1 on .NET, you'll need a commercial license for Saxon EE (full product) or EE-V (validation package). Note that a Saxon license will allow you to use the library on both .NET and Java platforms. See Saxonica's product page, feature matrix, and licensing for further details.