In this tutorial, I'll show you how to create a class from xsd file using xsd.exe tool and fix 'Schema validation warning: The 'http://www.w3.org/2000/09/xmldsig#:Signature' element is not declared.' or 'Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.'
XML Schema Definition (XSD) is a recommendation of the World Wide Web Consortium (W3C), specifies how to formally describe the elements in an Extensible Markup Language (XML) document. It can be used by programmers to verify each piece of item content in a document.
To generate class from xsd file you need to Open Developer Command Prompt for VS 2017, then use command the following to create your class.
Don't forget copy your xsd file into your working directory.
xsd.exe invoice.xsd /Classes
You will get an error as shown below
C:\Publish>xsd.exe invoice.xsd /Classes Microsoft (R) Xml Schemas/DataTypes support utility [Microsoft (R) .NET Framework, Version 4.6.1055.0] Copyright (C) Microsoft Corporation. All rights reserved. Schema validation warning: The 'http://www.w3.org/2000/09/xmldsig#:Signature' element is not declared. Line 100, position 10. Warning: Schema could not be validated. Class generation may fail or may produce incorrect results. Error: Error generating classes for schema 'invoice'. - The element 'http://www.w3.org/2000/09/xmldsig#:Signature' is missing. If you would like more help, please type "xsd /?".
To solve the problem above you should download the xmldsig-core-schema.xsd from https://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd, then copy the xmldsig-core-schema.xsd file to the same directory of your xsd file
Modify your command as shown below, then run again
xsd.exe invoice.xsd /Classes xmldsig-core-schema.xsd
See the screenshot below
You can see the invoice_xmldsig-core-schema.cs file created in the same directory as your xsd file.