Validate XML message against XSD schema?

I have an Ens.StreamContainer which holds XML that was received, and I need to validate that against an XSD schema. The schema is very simple, only looking at the root element and maybe a couple other items to ensure the XML is what we expect before continuing the data flow.

I have imported my XSD into the Ensemble XSD wizard, so it is available, but I'm struggling to find a method that does the validation. I thought about possibly using the schema to generate a class definition, then attempt to load the XML as that object (try/catch to handle the failure scenario), but I don't know where to start on that either.

I have looked at %XML.Schema and EnsLib.EDI.XML.Schema classes, to no avail, but I believe I'm probably missing something.

Thanks in advance!

  • 0
  • 0
  • 33
  • 0
  • 1

Answers

Use ValidateStream method of Ens.Util.XML.Validator class. It does exactly what you need.