davidjava
asked on
Creating a schema which imports some other schemas
I have 3 basic schemas which both Xerces-C++ and XMLSpy claim to be valid: Nikon.xsd, Olympus.xsd and Pentax.xsd.
Then I try to create a new schema (Camera.xsd) which imports the definitions of the 3 basic schemas in order to create a more complex new element. Both Xerces and XMLSpy show an error which says that types with name nikon:body_type, olympus:lens_type and pentax:manual_adapter_type have not been defined in current nor included/imported schemas.
I cannot find the error which prevents the new schema from being properly validated. Some advice would be appreciated.
Best regards,
David
--------------------- Nikon.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.nikon.com"
targetNamespace="http://www.nikon.com"
elementFormDefault="qualif ied"
attributeFormDefault="qual ified">
<xsd:element name="body_type">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
--------------------- Olympus.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.olympus.com"
targetNamespace="http://www.olympus.com"
elementFormDefault="qualif ied"
attributeFormDefault="qual ified">
<xsd:element name="lens_type">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="zoom" type="xsd:string"/>
<xsd:element name="f-stop" type="xsd:decimal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
--------------------- Pentax.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.pentax.com"
targetNamespace="http://www.pentax.com"
elementFormDefault="qualif ied"
attributeFormDefault="qual ified">
<xsd:element name="manual_adapter_type" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="speed" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
--------------------- Camera.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.camera.org"
targetNamespace="http://www.camera.org"
xmlns:nikon="http://www.nikon.com"
xmlns:olympus="http://www.olympus.com"
xmlns:pentax="http://www.pentax.com"
elementFormDefault="qualif ied"
attributeFormDefault="qual ified">
<xsd:import namespace="http://www.nikon.com"
schemaLocation="Nikon.xsd" />
<xsd:import namespace="http://www.olympus.com"
schemaLocation="Olympus.xs d"/>
<xsd:import namespace="http://www.pentax.com"
schemaLocation="Pentax.xsd "/>
<xsd:element name="camera">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="body" type="nikon:body_type"/>
<xsd:element name="lens" type="olympus:lens_type"/>
<xsd:element name="manual_adapter" type="pentax:manual_adapte r_type"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Then I try to create a new schema (Camera.xsd) which imports the definitions of the 3 basic schemas in order to create a more complex new element. Both Xerces and XMLSpy show an error which says that types with name nikon:body_type, olympus:lens_type and pentax:manual_adapter_type
I cannot find the error which prevents the new schema from being properly validated. Some advice would be appreciated.
Best regards,
David
--------------------- Nikon.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.nikon.com"
targetNamespace="http://www.nikon.com"
elementFormDefault="qualif
attributeFormDefault="qual
<xsd:element name="body_type">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
--------------------- Olympus.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.olympus.com"
targetNamespace="http://www.olympus.com"
elementFormDefault="qualif
attributeFormDefault="qual
<xsd:element name="lens_type">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="zoom" type="xsd:string"/>
<xsd:element name="f-stop" type="xsd:decimal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
--------------------- Pentax.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.pentax.com"
targetNamespace="http://www.pentax.com"
elementFormDefault="qualif
attributeFormDefault="qual
<xsd:element name="manual_adapter_type"
<xsd:complexType>
<xsd:sequence>
<xsd:element name="speed" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
--------------------- Camera.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.camera.org"
targetNamespace="http://www.camera.org"
xmlns:nikon="http://www.nikon.com"
xmlns:olympus="http://www.olympus.com"
xmlns:pentax="http://www.pentax.com"
elementFormDefault="qualif
attributeFormDefault="qual
<xsd:import namespace="http://www.nikon.com"
schemaLocation="Nikon.xsd"
<xsd:import namespace="http://www.olympus.com"
schemaLocation="Olympus.xs
<xsd:import namespace="http://www.pentax.com"
schemaLocation="Pentax.xsd
<xsd:element name="camera">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="body" type="nikon:body_type"/>
<xsd:element name="lens" type="olympus:lens_type"/>
<xsd:element name="manual_adapter" type="pentax:manual_adapte
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<xsd:element name="body" type="nikon:body_type"/>
here the xsd:element body points to a xsd:complexType or xsd:simpleType element having the name body_type. It does not point to xsd:elements. xsd:complexTypes and xsd:simpleTypes do not appear as elements outright.
here the xsd:element body points to a xsd:complexType or xsd:simpleType element having the name body_type. It does not point to xsd:elements. xsd:complexTypes and xsd:simpleTypes do not appear as elements outright.
ASKER