[xml] How to reference a local XML Schema file correctly?

I'm having this problem with referencing my XML Schema in an XML file.

I have my XSD in this path:

C:\environment\workspace\maven-ws\ProjectXmlSchema\email.xsd

But when in my XML file I'm trying to locate the schema like this, the XSD is not found:

<?xml version="1.0" encoding="UTF-8" ?>
    <email xmlns="http://www.w3schools.com"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.w3schools.com
                 file://C://environment//workspace//maven-ws//ProjextXmlSchema//email.xsd">

The only way the XSD is found is when it's in the same folder:

           xsi:schemaLocation="http://www.w3schools.com email.xsd"

So the question is this: How does the path have to look so that the XSD will be found if the XML file wasn't in the same folder as the XSD file?

By the way, the example I've been using was from MSDN: they're claiming it's supposed to work the way I tried to. But it doesn't.

This question is related to xml xsd

The answer is


If you work in MS Visual Studio just do following

  1. Put WSDL file and XSD file at the same folder.
  2. Correct WSDL file like this YourSchemeFile.xsd

  3. Use visual Studio using this great example How to generate service reference with only physical wsdl file

Notice that you have to put the path to your WSDL file manually. There is no way to use Open File dialog box out there.


Maybe can help to check that the path to the xsd file has not 'strange' characters like 'é', or similar: I was having the same issue but when I changed to a path without the 'é' the error dissapeared.