W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2002

Re: xsd:import

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 10 Jul 2002 09:01:03 +0100
Message-ID: <97332215130.20020710090103@jenitennison.com>
To: "zze-MARCHEGAY Michael stagiaire FTRD/DTL/LAN" <michael.marchegay@rd.francetelecom.com>
CC: xmlschema-dev@w3c.org

Hi MichaŽl,

> I have a question concerning importation: if two schema have the
> same targetNamespace, can they be both imported by a third schema?

As Ajay said, most validators will ignore the second import, so while
you *can* have two imports for the same namespace, it won't
necessarily give you what you want. It's better to create a schema
that includes both of the other schemas, and then import that:

<!--A.xsd-->
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"        
        targetNamespace="http://foo.com/A.xsd">
        <xsd:import namespace="http://foo.com/foo" schemaLocation="D.xsd"/>
        <xsd:element name="e1" type="xsd:integer"/>
</xsd:schema>

<!--D.xsd-->
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://foo.com/foo">
        <xsd:include schemaLocation="B.xsd" />
        <xsd:include schemaLocation="C.xsd" />
</xsd:schema>

<!--B.xsd-->
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://foo.com/foo">
        <xsd:element name="e2" type="xsd:integer"/>
</xsd:schema>

<!--C.xsd-->
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://foo.com/foo">
        <xsd:element name="e3" type="xsd:integer"/>
</xsd:schema>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 10 July 2002 04:01:05 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:57 UTC