问题
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