Proper way to define the schema for 'CustomDictionary.xml' in Visual Studio (2013)?

我的梦境 提交于 2019-12-07 01:19:45

问题


I'm making use of a custom dictionary (CustomDictionary.xml) for Code Analysis, and it is working like it should. But, I keep getting warnings that indicate to me that the XML file is not defining its XSD schema location properly:

I found the XSD (CustomDictionary.xsd) on my machine, and I specified the scheme of its URI as type file:

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

With this URI, Chrome is able to locate the XSD file just fine. That said, how do I properly reference CustomDictionary.xsd from within CustomDictionary.xml?

What I have found so far indicates that the following should work, but it is not:

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

(Note that I have truncated the path to CustomDictionary.xsd for clarity.)

Any suggestions on what I'm doing wrong?


回答1:


Add CustomDictionary.xsd into your project. And in your XML file, CustomDictionary.xml, add the xmlns:xsi and xsi:noNamespaceSchemaLocation attributes to the Dictionary element as follows:

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


来源:https://stackoverflow.com/questions/26638054/proper-way-to-define-the-schema-for-customdictionary-xml-in-visual-studio-201

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!