11

It would be nice to be able to validate incoming and outgoing e-invoices against their schema definition XSD.


There is a good C# example from Microsoft on how to do this:

https://learn.microsoft.com/en-us/dotnet/standard/data/xml/xml-schema-xsd-validation-with-xmlschemaset#validate-xml-documents


I have adapted it to be valid against the PEPPOL Bis 3.0 UBL definition:

static void Main(string[] args)

{

XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();

xmlReaderSettings.Schemas.Add("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2", "https://docs.oasis-open.org/ubl/csd02-UBL-2.4/xsd/maindoc/UBL-Invoice-2.4.xsd");

xmlReaderSettings.ValidationType = ValidationType.Schema;

xmlReaderSettings.ValidationEventHandler += SettingsValidationEventHandler;

var fileStream = new FileStream("Cronus - Inovice 688001360.xml", FileMode.Open);

XmlReader xmlReader = XmlReader.Create(fileStream, xmlReaderSettings);


while (xmlReader.Read()) { }

}


static void SettingsValidationEventHandler(object sender, ValidationEventArgs e)

{

   if (e.Severity == XmlSeverityType.Warning)

   {

       Console.Write("WARNING: ");

       Console.WriteLine(e.Message);

   }

   else if (e.Severity == XmlSeverityType.Error)

   {

       Console.Write("ERROR: ");

       Console.WriteLine(e.Message);

   }

}

STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for your feedback. Currently this is not in our roadmap; however, we are tracking it and if we get more feedback and votes, we may consider it in the future.

Sincerely,
Aleksandar Totovic
PM, Microsoft