1

How can I use Visual Studio 2017 to validate my XML with referenced public XSD schemas?

In Visual Studio 2017, first I enable "Automatic Download of DTDs and Schemas" under tools->Options->Text Editor->XML->Miscellaneous. Then, when I specify an XML document that includes and xsi:schemaLocation, Visual Studio fails to load the referenced schema and I can't take advantage of the Visual Studio features like XML validation and intellisense editing.

Here is an example, take the standard conforming example document from VXML 2.1

<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://www.w3.org/2001/vxml 
  http://www.w3.org/TR/2007/REC-voicexml21-20070619/vxml.xsd">

  <form>
    <block>hello</block>
  </form>

</vxml>

If I enter this as an XML document in Visual Studio a get a bunch of warnings:

The operation has timed out
The schema referenced from this location in your document contains errors

I think this answer from @Petru Gardea is similar to my problem - https://stackoverflow.com/a/21562249/90236 - W3C apparently throttles their servers and tools like Visual Studio will timeout. The suggestion in the answer above is to bring the XSD file local and update the xsd path. Unfortunately, a complex schema will bring in may other schemas by xsd:include or xsd:import. I have not been able to get all the included schemas properly download for this to work.

Isn't Visual Studio supposed to download and cache the referenced schemas as part of the XML Schema set? Do I have to manually download and add some schemas to the set as described in XML Validation with XSD in Visual Studio IDE ?

Other tools, most notably XMLSpy, just do the right thing and validation works great. Can I get this to work in Visual Studio?

-- update --

I found this post W3C’s Excessive DTD Traffic. But it isn't clear to me what the accepted solution is. Shouldn't Visual Studio manage an XML catalog for the schemas? I've also been told that w3.org won't respond to XSD requests without a valid user-agent header. Is this why my operation is timing out?

Michael Levy
  • 13,097
  • 15
  • 66
  • 100
  • Did you ever find a solution for this? – StackOverthrow May 22 '20 at 19:12
  • No. Unfortunately, I never found a good solution. I also have not retested with Visual Studio 2019. Maybe it has better behavior. I ended up using a evaluation copy of XMLspy. Which did a great job validating against the schemas. That 30 day trial (or whatever it was) was all I needed for that project. – Michael Levy May 23 '20 at 18:23
  • 1
    VS2019 is no better. Not willing to spend over $500 for a text editor with basic XML schema validation, I found a plugin for Notepad++ that does the job well enough. – StackOverthrow Jun 16 '20 at 23:08
  • I had tested Notepad++ plugin, but they didn't help. I just upgraded to XML Tools 3.0.4.2 and it seems to do a good job. Thanks. – Michael Levy Jun 17 '20 at 13:10

1 Answers1

2

I had a similar issue in VS2015: When I tried to use a dtd or xsd file for validation/intellisense, I received error messages. I tried to delete the schemas in the Schema selector, but some sharepoint related shema was remained (not deleted).

Finally I've renamed the folders where these shemas were located, and the intellisense started to work (after restart VS). The folder is the following:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\XML