Importing local schema

This should cover W3C XML Schema, Relax NG and DTD related problems.
rwaltz
Posts: 2
Joined: Thu Jul 07, 2005 12:55 am

Importing local schema

Post by rwaltz »

Newbie question here.

I'm trying to extend an element in an existing schema in the following way (I've snipped what I've thought is pertinent and changed some names to protect the innocent) :

existing schema :

<?xml version="1.0" encoding="UTF-8"?>
<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="urn:schemas:device:local"
targetNamespace="urn:schemas:device:local"
elementFormDefault="qualified">

<s:complexType name="TESTING">
<s:sequence>
<s:element name="serial-number" type="s:anyURI"/>
<s:element name="modelname" type="s:string"/>
<s:element name="location" type="s:string"/>
<s:element name="mac_address" type="s:string"/>
</s:complexType>
</s:schema>

extension :

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ns1="urn:schemas:device:local2"
targetNamespace="urn:schemas:device:local2"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:local="urn:schemas:device:local">

<xs:import namespace="urn:schemas:device:local"
schemaLocation="urn:schemas:device:local
./local.xsd"/>

<xs:complexType name="DeviceDescription">
<xs:complexContent>
<xs:extension base="local:DEVICE_INFO_TYPE">
<xs:sequence>
<xs:element name="DeviceName" type="xs:string"/>
<xs:element name="EventSink" type="xs:anyURI"/>
<xs:element name="VersionNumber" type="xs:string"/>
<xs:element name="ServiceMode" type="xs:boolean"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>


I get the following error :

SystemID: Z:\XXX\XML\local2.xsd
Location: 12:46
Description: E src-resolve.4.2: Error resolving component 'local:DEVICE_INFO_TYPE'. It was detected that 'local:DEVICE_INFO_TYPE' is in namespace './local.xsd', but components from this namespace are not referenceable from schema document 'file:/Z:/XXX/XML/local2.xsd'. If this is the incorrect namespace, perhaps the prefix of 'local:DEVICE_INFO_TYPE' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/Z:/XXX/XML/sharplocal.xsd'.
URL: http://www.w3.org/TR/xmlschema-1/#src-resolve


So, it looks like my import tag is not correct. The schema name and the path are correct, what am I missing? Both files reside in the same directory - I haven't exposed these via a website because I'm just doing local development and didn't think I needed to.

Thanks for any advice.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

<xs:import namespace="urn:schemas:device:local"
schemaLocation="urn:schemas:device:local
./local.xsd"/>
The schema location in case of an import does not take as value a list of pairs or a pair of the forma namespace followed by location as it is the case with xsi:schemaLocation. You already have the namespace specified in the namespace attribute, you need to specify only the location in the schemaLocation attribute:

Code: Select all


<xs:import namespace="urn:schemas:device:local"
schemaLocation="local.xsd"/>
Best Regards,
George
rwaltz
Posts: 2
Joined: Thu Jul 07, 2005 12:55 am

Thanks

Post by rwaltz »

That did it. Thank you.
Post Reply