复杂的模式验证问题
我即将实现在 ASP.NET MVC 3 项目中对视图进行单元测试的目标。我将 XML 输出作为字符串,并希望根据标准 VoiceXML 2.1 架构进行验证。我从 w3.org 下载了上述架构,但有两个问题:
- 验证需要几分钟
- 我收到错误“引用未声明的模型组 'http://www.w3.org/2001/vxml:audio'”。
我怀疑原因是主模式引用了通过网络检索(或不检索)的几个包含的模式。我在架构文件中看到以下内容:
<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"/>
我正在单元测试中加载架构,如下所示:
XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add("http://www.w3.org/2001/vxml", "../../../IVRUnitTests/VoiceXML21Schema.xsd");
settings.ValidationType = ValidationType.Schema;
settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
我已经下载了主文件中引用的包含架构。我还可以将它们添加到我的 XmlReaderSettings.Schemas 集合中吗?如果是这样,验证是否不会在网络上查找它们?对于验证如此复杂的模式还有其他建议吗?
PS 将模式放在单元测试项目中的最佳位置在哪里,以便它会在我需要的地方自动复制/引用? “../../”这个东西很混乱。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论