[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Redefine and Import used together - is this valid?

From: Henry S. Thompson <ht@inf.ed.ac.uk>
Date: Tue, 19 Sep 2006 17:19:07 +0100
To: Danny Vint <dvint@sack.dreamhost.com>
Cc: xmlschema-dev@w3.org, xml-dev@lists.xml.org
Message-ID: <f5bfyeng77o.fsf@erasmus.inf.ed.ac.uk>
Re: Redefine and Import used together - is this valid?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Danny Vint writes:

> [not happy depending on optionality of following 'schemaLocation' hint]

Let's go back to your requirements.

Here is a minimal example of your (1) -- (3):

(1) ACORD.xsd:
<xs:schema targetNamespace="http://www.example.com/ACORD">
 <xs:complexType name="ACType">
  <xs:sequence>
   <xs:element name="AElt1"/>
   <xs:element name="AElt2"/>
  </xs:sequence>
 </xs:complexType>
 
 <xs:simpleType name="ASType">
  <xs:restriction base="xs:token">
   <xs:enumeration value="red"/>
   <xs:enumeration value="white"/>
   <xs:enumeration value="blue"/>
  </xs:restriction>
 </xs:simpleType>
</xs:schema>

(2) ACME.xsd:
<xs:schema xmlns:ac="http://www.example.com/ACORD"
           targetNamespace="http://www.example.com/ACME">
 <xs:import namespace="http://www.example.com/ACORD"
            schemaLocation="ACORD.xsd"/>
 <xs:element name="MyE" type="ac:ASType"/>
</xs:schema>

(3) AA.xsd:
<xs:schema targetNamespace="http://www.example.com/ACORD"
           xmlns:ac="http://www.example.com/ACORD"
           xmlns:my="http://www.example.com/ACME">
 <xs:import namespace="http://www.example.com/ACME"
            schemaLocation="ACME.xsd"/>
 <xs:redefine schemaLocation="ACORD.xsd">
  <xs:complexType name="ACType">
   <xs:complexContent>
    <xs:extension base="ac:ACType">
     <xs:sequence>
      <xs:element ref="my:MyE"/>
     </xs:sequence>
    </xs:extension>
   </xs:complexContent>
  </xs:complexType>
 </xs:redefine>
</xs:schema>

So, as you already observed, this works with XSV, but not with all
tools.

The problem arises when ACORD.xsd is processed twice, producing two
conflicting definitions of ACType.

So, to fix this, we want to prevent the double processing.  Proposed
solution (I don't have access to the tool you're having trouble with):
remove the offending hint.

That is, change ACME.xsd:
<xs:schema xmlns:ac="http://www.example.com/ACORD"
           targetNamespace="http://www.example.com/ACME">
 <xs:import namespace="http://www.example.com/ACORD"/>
 <xs:element name="MyE" type="ac:ASType"/>
</xs:schema>

This is still a valid schema document.  And now processing AA.xsd
should not provoke any conflicts, as only the redefined type
definition will be created.

Hope this helps,

ht
- -- 
 Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                     Half-time member of W3C Team
    2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
            Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
                   URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFFEBh8kjnJixAXWBoRAtPMAJ4yRcZAcS9gGluHBa1L2lvbpftpZQCfUB+H
uq5THzzXuL83hDTdyPv7lv4=
=trT+
-----END PGP SIGNATURE-----
Received on Tuesday, 19 September 2006 16:19:29 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.