I am using XmlReader
to validate a XML file as per the supplied schema.
For that I am creating an instance of XmlReaderSettings
and setting it's ValidationType
as ValidationType.Schema
and it's Schemas
Property as XxmlSchemaSet. A draft code is like
XmlReaderSettings rSettings = new XmlReaderSettings();
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add(null, xsdPath1);
schemaSet.Add(null, xsdPath2);
schemaSet.Add(null, xsdPath3);
rSettings.Schemas.Add(schemaSet);
rSettings.ValidationType = ValidationType.Schema;
XmlReader validatingReader = XmlReader.Create(sr, rSettings);
sr is a StreamReader
This is actually legacy code and still has many problems which I have to fix. I know that schemaSet.Add(null, xsdPath2)
looks nasty and ugly which I am going to fix.
What I want to ask is that since I have provided three xsd files, what performance hits should I expect? The xsd's are given in decreasing order of priority. All these XML schema are versioned, so I have added all of them so as to have a fallback mechanism.
What I am thinking was that JIT compiler will compiler only xsd1 try to parse the XML file with it and if it fails moves to next. I don't want all of the three xsd to be in memory.
This is where I am confused. What performance hit can I expect in specifying multiple schema files?
I am expected to improve the legacy codebase, so performance is always on the top.