- From: Calvin Smith <calvins@SIMS.Berkeley.EDU>
- Date: Mon, 22 Jul 2002 16:23:29 -0700 (PDT)
- To: xmlschema-dev@w3.org
Hi, 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" xmlns="http://www.test.com/sample" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:complexType name="AddressType"> <xsd:sequence> <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"/> </xsd:sequence> </xsd:complexType> </xsd:schema> schema2: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:s="http://www.test.com/sample" targetNamespace="http://www.test.com/sample2" xmlns="http://www.test.com/sample2" > <xsd:import namespace="http://www.test.com/sample" schemaLocation="sample.xsd"/> <xsd:complexType name="SimplerAddressType"> <xsd:complexContent> <xsd:restriction base="s:AddressType"> <xsd:sequence> <xsd:element name="State" type="xsd:string"/> <xsd:element name="Country" type="xsd:string"/> </xsd:sequence> </xsd:restriction> </xsd:complexContent> </xsd:complexType> <xsd:element name="Address" type="SimplerAddressType"/> </xsd:schema> And the instance document: <?xml version="1.0" encoding="UTF-8"?> <Address xmlns="http://www.test.com/sample2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.test.com/sample2 sample2.xsd"> <State>Ontario</State> <Country>Canada</Country> </Address> 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? thanks, calvin
Received on Monday, 22 July 2002 19:23:30 UTC