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

restriction question

From: Calvin Smith <calvins@SIMS.Berkeley.EDU>
Date: Mon, 22 Jul 2002 16:23:29 -0700 (PDT)
To: xmlschema-dev@w3.org
Message-ID: <Pine.GSO.4.44.0207221539340.15384-100000@info.sims.berkeley.edu>


Is it possible to derive by restriction, where the derived type is in a
different namespace than the base type?  The spec, at 3.9.6, doesn't
explicitly say, so I think it's probably okay.  Xerces2, however,
complains that it isn't a valid restriction.

This illustrates the problem:

schema 1:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.test.com/sample"
elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xsd:complexType name="AddressType">
      <xsd:element name="Street" type="xsd:string" minOccurs="0"/>
      <xsd:element name="State" type="xsd:string" minOccurs="0"/>
      <xsd:element name="Country" type="xsd:string" minOccurs="0"/>


<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://www.test.com/sample2" >
  <xsd:import namespace="http://www.test.com/sample" schemaLocation="sample.xsd"/>
  <xsd:complexType name="SimplerAddressType">
      <xsd:restriction base="s:AddressType">
          <xsd:element name="State" type="xsd:string"/>
          <xsd:element name="Country" type="xsd:string"/>
  <xsd:element name="Address" type="SimplerAddressType"/>

And the instance document:

<?xml version="1.0" encoding="UTF-8"?>
<Address xmlns="http://www.test.com/sample2"
xsi:schemaLocation="http://www.test.com/sample2 sample2.xsd">

Xerces issues the following error message upon trying to validate the
instance document against schema2:

Error:  org.xml.sax.SAXParseException: rcase-Recurse.2: There is not a
complete functional mapping between the particles
Error:  org.xml.sax.SAXParseException: derivation-ok-restriction.5.3:
Error for type 'SimplerAddressType'.  The particle
 of the type is not a valid restriction of the particle of the base.

I read what I thought was the relevant part of the schema (3.9.*), and it
seemed like this is derivation is okay, but Xerces doesn't like it, and a
similar kind of restriction was giving XML Spy trouble, too.

Any advice?


Received on Monday, 22 July 2002 19:23:30 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:04 UTC