我在XML文件中引用我的XML Schema时遇到了这个问题.
我在这条道路上有我的XSD:
C:\environment\workspace\maven-ws\ProjectXmlSchema\email.xsd
Run Code Online (Sandbox Code Playgroud)
但是当我在我的XML文件中尝试找到这样的架构时,找不到XSD:
<?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">
Run Code Online (Sandbox Code Playgroud)
找到XSD的唯一方法是它在同一个文件夹中:
xsi:schemaLocation="http://www.w3schools.com email.xsd"
Run Code Online (Sandbox Code Playgroud)
所以问题是:如果XML文件与XSD文件不在同一个文件夹中,那么路径必须如何才能找到XSD?
顺便说一句,我一直在使用的例子来自MSDN:他们声称它应该按照我试图的方式工作.但事实并非如此.
我想在.xsd文件中定义浏览器中的xml文件.请为我检查以下两个文件,并指出我需要做什么.这两个文件位于同一文件夹下.
employee.xml
<?xml version="1.0"?>
<employee xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="employee.xsd">
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
Run Code Online (Sandbox Code Playgroud)
的employee.xsd
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string" fixed="red" />
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)