Complex schema validation issues
I'm close to achieving the goal of unit testing views in an ASP.NET MVC 3 project. I have the XML output as a string, and want to validate against the standard VoiceXML 2.1 schema. I downloaded said schema from w3.org, but two issues:
- Validation takes several minutes
- I'm getting an error "reference to undeclared model group 'http://www.w3.org/2001/vxml:audio'".
I suspect the reason is that the main schema refers to several included schemas that are being retrieved (or not) over the web. I'm seeing the following in the schema file:
<xsd:include schemaLocation="vxml-datatypes.xsd"/>
<xsd:include schemaLocation="vxml-attribs.xsd"/>
<xsd:include schemaLocation="vxml-grammar-extension.xsd"/>
<xsd:include schemaLocation="vxml-synthesis-extension.xsd"/>
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/xml.xsd"/>
I'm loading the schema in my unit test as follows:
XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add("http://www.w3.org/2001/vxml", "../../../IVRUnitTests/VoiceXML21Schema.xsd");
settings.ValidationType = 开发者_运维问答ValidationType.Schema;
settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
I've downloaded the included schemas referenced in the main one. Can I also add them to my XmlReaderSettings.Schemas collection? If so, will the validation not go looking over the web for them? Any other advice for validating against such a complex schema?
P.S. Where's the best place to put the schema in the unit test project so it will automatically be copied/referenced where I need it? The '../../' thing is kludgey.
精彩评论