在Visual Studio(2013)中定义"CustomDictionary.xml"架构的正确方法?

Eri*_*ric 7 xml xsd code-analysis visual-studio visual-studio-2013

我正在使用自定义词典(CustomDictionary.xml)进行代码分析,它的工作方式应该如此.但是,我不断收到警告,告诉我XML文件没有正确定义其XSD架构位置:

CustomDictionary.xml警告

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

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

使用此URI,Chrome可以很好地找到XSD文件.那就是说,我如何CustomDictionary.xsd从内部正确引用CustomDictionary.xml?

到目前为止我发现的内容表明以下内容应该有效,但事实并非如此:

<Dictionary
  xmlns="http://www.w3schools.com"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.w3.org/ file:/.../CustomDictionary.xsd">
Run Code Online (Sandbox Code Playgroud)

(请注意,CustomDictionary.xsd为了清楚起见,我已经截断了路径.)

关于我做错的任何建议?

cil*_*ler 7

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

<Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="CustomDictionary.xsd">
Run Code Online (Sandbox Code Playgroud)