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

RE: restriction question

From: Dare Obasanjo <dareo@microsoft.com>
Date: Mon, 22 Jul 2002 17:15:34 -0700
Message-ID: <8BD7226E07DDFF49AF5EF4030ACE0B7E06621E25@red-msg-06.redmond.corp.microsoft.com>
To: "Calvin Smith" <calvins@SIMS.Berkeley.EDU>
Cc: <xmlschema-dev@w3.org>

elementFormDefault should be unqualified in both schemata or the types
in your complex type's content model should reference the same ones. 

-- 
PITHY WORDS OF WISDOM 
He who laughs last didn't catch on very fast, did he? 

This posting is provided "AS IS" with no warranties, and confers no
rights. 



> -----Original Message-----
> From: Calvin Smith [mailto:calvins@SIMS.Berkeley.EDU] 
> Sent: Monday, July 22, 2002 5:08 PM
> To: Dare Obasanjo
> Cc: xmlschema-dev@w3.org
> Subject: RE: restriction question
> 
> 
> Thanks, Dare.  I tried setting elementFormDefault to 
> unqualified (I think you meant either/or with the two 
> suggestions), and then Xerces complains
> that:
> 
> Error:  org.xml.sax.SAXParseException: 
> cvc-complex-type.2.4.a: Invalid content starting with element 
> 'State'. The content must match '(("":State),("":Country))'.
> 
> This is because of the default namespace, right?
> 
> What I would like to do is restrict a type from a foreign 
> schema/namespace
> -- which I have no control over -- in a namespace that I do 
> have control over, and I would like to have the default 
> namespace be equal to the target namespace in my schema.  Is 
> this possible?  If I have understood you properly, then this 
> isn't possible if the foreign namespace schema has 
> elementFormDefault set to 'qualified'. Is this correct?  Do I 
> have to not use the xmlns=targetNamespace?
> 
> 
> thanks,
> 
> calvin
> 
> On Mon, 22 Jul 2002, Dare Obasanjo wrote:
> 
> > Your schema is invalid and the reason is given in the error message 
> > provided by Xerces which has nothing to do with the types being in 
> > different namespaces. Although the problem is due to namespaces.
> >
> > Both schemas define local elements yet set 
> > elementFormDefault="qualified". This means that the Street, 
> State and 
> > Country elements in schema 1 are from the 
> http://www.test.com/sample 
> > namespace while the State and Country elements in schema 2 are from 
> > the http://www.test.com/sample2 namespace. Thus 
> SimplerAddressType is 
> > not a valid restriction of AddressType. To solve this 
> problem you can 
> > do two things
> >
> > 1.) Change the value of elementFormDefault to unqualified 
> or remove it 
> > entirely since the default is unqualified.
> >
> > 2.) Define the Street, State and Country in a single schema 
> [in schema 
> > 1, schema 2 or a new one] and reference those types from 
> your complex 
> > type definitions.
> >
> > --
> > PITHY WORDS OF WISDOM
> > He who laughs last didn't catch on very fast, did he?
> >
> > This posting is provided "AS IS" with no warranties, and confers no 
> > rights.
> >
> >
> >
> > > -----Original Message-----
> > > From: Calvin Smith [mailto:calvins@SIMS.Berkeley.EDU]
> > > Sent: Monday, July 22, 2002 4:23 PM
> > > To: xmlschema-dev@w3.org
> > > Subject: restriction question
> > >
> > >
> > >
> > > 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 20:16:06 UTC

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