I have a two xsd files "first.xsd" and "second.xsd".
Inside second.xsd, I want to refer to an element defined in first.xsd (with different namespace).
My second.xsd looks like:
<xs:schema ... xmlns:schema1="http://www.schema.org/schema1" targetNamespace "http://www.schema.org/schema2 ... >
<xs:import namespace = "http://www.schema.org/schema1" schemaLocation = "first.xsd" />
<xs:element name = "complex1">
<xs:complexType>
.........
<xs:element ref="schema1:name2"/>
.........
</xs:complexType>
</xs:element>
Now I want to include and import second.xsd inside first.xsd So I do the following in first.xsd:
<xs:schema ... xmlns:schema2="http://www.schema.org/schema2" targetNamespace "http://www.schema.org/schema1 ... >
<xs:import namespace="http://www.schema.org/schema2" schemaLocation="second.xsd">
<xs:element name = "name1"/>
<xs:element name = "name2"/>
<xs:element name = "name3"/>
Is this the right way to do since I not able to successfully validate the schema.
Is it a problem because of some cyclic namespace inclusion??
I'm using oxygen xml developer to validate the schema files and my first.xsd when validated says:
E[Xerces] src-resolve: Cannot resolve the name to a(n) type definition component. (second.xsd)
But if I validate the second.xsd file separately it says schema valid.
In my actual case I have a very complex scenario so I've boiled it down to a simple example as shown above.
Could someone please help.