[ACCEPTED]-How to specify an XSD schemaLocation attribute in VS when the referenced schema file is in a different project/assembly?-xsd
XSD only supports URI locations, not path 2 location. This means that file:///C:/path/to/VS/Projects/ReferencedProject/Data/ReferencedSchema.xsd
is valid, but 1 not ../../ReferencedProject/Data/ReferencedSchema.xsd
.
Disclaimer: I don't know a lot about XML 6 schema. Anyway, I ran into the same problem 5 as you.
Using xs:import rather than xs:include 4 seemed to solve my problem in VS designer.
First 3 schema:
<xs:schema id="schema1"
targetNamespace="http://tempuri.org/schema1.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/schema1.xsd"
xmlns:mstns="http://tempuri.org/schema1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="MyType" nillable="true"/>
<xs:complexType name="MyType">
<xs:all>
<xs:element name="Value1" type="xs:double"/>
<xs:element name="Value2" type="xs:double"/>
</xs:all>
</xs:complexType>
</xs:schema>
Second schema:
<xs:schema id="schema2"
targetNamespace="http://tempuri.org/schema2.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/schema2.xsd"
xmlns:mstns="http://tempuri.org/schema2.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:schema1="http://tempuri.org/schema1.xsd"
>
<xs:import namespace="http://tempuri.org/schema1.xsd"/>
<xs:element name="MySecondType" nillable="true"/>
<xs:complexType name=MySecondType>
<xs:element name="Value" type="schema1:MyType/>
</xs:complexType>
</xs:schema>
When editing XML schema 2 in Visual Studio, you can see which schema's 1 are active using menu item XML --> Schemas.
Use a public URL or a common network share 1 put both files at that location.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.