复杂的架构验证问题

时间:2011-10-14 18:46:08

标签: c# .net xml xsd

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

  1. 验证需要几分钟
  2. 我收到错误“引用未声明的模型组'http://www.w3.org/2001/vxml:audio'”。
  3. 我怀疑原因是主模式引用了通过Web检索(或不检索)的几个包含模式。我在架构文件中看到以下内容:

    <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集合中吗?如果是这样,验证是否会为他们查看网页?验证这种复杂模式的任何其他建议吗?

    P.S。哪里是将模式放在单元测试项目中的最佳位置,以便在需要时自动复制/引用? '../../'的事情是kludgey。

0 个答案:

没有答案
相关问题