复杂的模式验证问题

发布于 2024-12-09 15:49:23 字数 1184 浏览 0 评论 0原文

我即将实现在 ASP.NET MVC 3 项目中对视图进行单元测试的目标。我将 XML 输出作为字符串,并希望根据标准 VoiceXML 2.1 架构进行验证。我从 w3.org 下载了上述架构,但有两个问题:

  1. 验证需要几分钟
  2. 我收到错误“引用未声明的模型组 '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:

  1. Validation takes several minutes
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文