How to reference a local XML Schema file correctly?

前端 未结 3 1250
别跟我提以往
别跟我提以往 2020-11-22 15:36

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\\ProjectXmlS         


        
相关标签:
3条回答
  • 2020-11-22 16:08

    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.

    0 讨论(0)
  • 2020-11-22 16:08

    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.

    0 讨论(0)
  • 2020-11-22 16:11

    Add one more slash after file:// in the value of xsi:schemaLocation. (You have two; you need three. Think protocol://host/path where protocol is 'file' and host is empty here, yielding three slashes in a row.) You can also eliminate the double slashes along the path. I believe that the double slashes help with file systems that allow spaces in file and directory names, but you wisely avoided that complication in your path naming.

    xsi:schemaLocation="http://www.w3schools.com file:///C:/environment/workspace/maven-ws/ProjextXmlSchema/email.xsd"
    

    Still not working? I suggest that you carefully copy the full file specification for the XSD into the address bar of Chrome or Firefox:

    file:///C:/environment/workspace/maven-ws/ProjextXmlSchema/email.xsd

    If the XSD does not display in the browser, delete all but the last component of the path (email.xsd) and see if you can't display the parent directory. Continue in this manner, walking up the directory structure until you discover where the path diverges from the reality of your local filesystem.

    If the XSD does displayed in the browser, state what XML processor you're using, and be prepared to hear that it's broken or that you must work around some limitation. I can tell you that the above fix will work with my Xerces-J-based validator.

    0 讨论(0)
提交回复
热议问题