【问题标题】:Proper way to define the schema for 'CustomDictionary.xml' in Visual Studio (2013)?在 Visual Studio (2013) 中定义“CustomDictionary.xml”架构的正确方法?
【发布时间】:2018-10-22 23:26:15
【问题描述】:

我正在使用自定义字典 ​​(CustomDictionary.xml) 进行代码分析,它的工作方式应有尽有。但是,我不断收到警告,提示我 XML 文件未正确定义其 XSD 架构位置:

我在我的机器上找到了 XSD (CustomDictionary.xsd),并将其 URI 的方案指定为类型file

file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2012.0/Team%20Tools/Static%20Analysis%20Tools/Schemas/CustomDictionary.xsd

有了这个 URI,Chrome 就可以很好地定位 XSD 文件。也就是说,我如何从CustomDictionary.xml 中正确引用CustomDictionary.xsd

到目前为止我发现表明以下应该工作,但它不是:

<Dictionary
  xmlns="http://www.w3schools.com"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.w3.org/ file:/.../CustomDictionary.xsd">

(请注意,为了清楚起见,我截断了指向 CustomDictionary.xsd 的路径。)

对我做错了什么有什么建议吗?

【问题讨论】:

    标签: xml visual-studio visual-studio-2013 xsd code-analysis


    【解决方案1】:

    CustomDictionary.xsd 添加到您的项目中。在您的 XML 文件 CustomDictionary.xml 中,将 xmlns:xsixsi:noNamespaceSchemaLocation 属性添加到 Dictionary 元素,如下所示:

    <Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="CustomDictionary.xsd">
    

    【讨论】:

      猜你喜欢
      • 2019-09-26
      • 2014-11-27
      • 1970-01-01
      • 2014-05-16
      • 2012-08-24
      • 1970-01-01
      • 2015-12-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多