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

RE: Deriving a simpleContent element from an anyType or anySimple Type

From: <Simon.Cox@csiro.au>
Date: Fri, 11 Jan 2002 18:55:03 +0800
Message-ID: <116D27C8E12BD411B3AB00B0D022B0B8AF0863@yate.wa.csiro.au>
To: xmlschema-dev@w3.org
XSV says OK to this pattern.  

But Xerces (via SQC) complains that xs:string is not a valid restriction of
xs:anySimpleType.  
Is this true?  The datatypes rec implies that anySimpleType is actually a
union of the simple types, rather than an ur-type.  Does this make any
difference?  

[XML Spy takes a different (wrong) line entirely ...]

_____
Simon.Cox@csiro.au  CSIRO Exploration & Mining
26 Dick Perry Avenue, Kensington WA 6151
PO Box 1130, Bentley WA 6102  AUSTRALIA
T: +61 (8) 6436 8639  F: +61 (8) 6436 8555  C: +61 (4) 0330 2672
http://www.csiro.au/page.asp?type=resume&id=CoxSimon

> -----Original Message-----
> From: ht@cogsci.ed.ac.uk [mailto:ht@cogsci.ed.ac.uk]
> Sent: Wednesday, 9 January 2002 5:24 PM
> To: Simon.Cox@csiro.au
> Cc: xmlschema-dev@w3.org
> Subject: Re: Deriving a simpleContent element from an anyType or
> anySimpleType
> 
> 
> Simon.Cox@csiro.au writes:
> 
> > This one comes up in various guises from time to time.  
> > I think I know the answer but I want to check.  
> > 
> > It is desirable to be able to define a type by restriction 
> > of an abstract type so that the content model is various specific
> > simpleTypes.  
> > One model pattern that was proposed goes like this.  Start with:
> > 
> > <xs:complexType name="baseType" abstract="true">
> >   <xs:attribute name="a1" type="string">
> > </xs:complexType>
> > 
> > which is an (empty) "anyType" by implication.  
> 
> Stop right there.  It's not any kind of "anyType", it's an empty
> complex type.  So you can't restrict its content in any useful way --
> empty is as restricted as it gets.
> 
> To get what you want (content model as per "anyType", one attribute),
> you need
> 
> <xs:complexType name="baseType" abstract="true">
>   <xs:sequence>
>    <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
>   </xs:sequence>
>   <xs:attribute name="a1" type="string">
> </xs:complexType>
> 
> 
> > Then "restrict" the content to be simpleContent.  e.g.:
> > 
> > <xs:complexType name="integerType">
> >    <xs:simpleContent>
> >      <xs:restriction base="baseType">
> >        <xs:simpleType>
> >          <xs:restriction base="xs:integer"/>
> >        </xs:simpleType>
> >      </xs:restriction>
> >    </xs:simpleContent>
> > </xs:complexType>
> > 
> > to get an integer with an attribute, and   
> > 
> > <xs:complexType name="stringType">
> >    <xs:simpleContent>
> >      <xs:restriction base="baseType">
> >        <xs:simpleType>
> >          <xs:restriction base="xs:string"/>
> >        </xs:simpleType>
> >      </xs:restriction>
> >    </xs:simpleContent>
> > </xs:complexType>
> > 
> > to get a string with the same attribute.  
> > 
> > Problem is, this appears to violate the third sub-clause of  
> > http://www.w3.org/TR/xmlschema-2/#defn-rep-constr 
> > 
> > Am I reading this right?  
> 
> There's a known issue here, the REC is contradictory, so some
> validators allow what I've shown above, and some don't.  There will be
> an erratum soon to fix the contradiction.
> 
> > So: is there a way to accomplish what I'm trying do here? 
> > (i.e. have various simpleContent types inherit the same 
> > attribute, and sit within a single type-derivation hierarchy, 
> > and thus be able to support elements that fit in a 
> substitutionGroup.)  
> 
> Yes, use this instead:
> 
> <xs:complexType name="baseType" abstract="true">
>   <xs:simpleContent>
>    <xs:extension base="xs:anySimpleType">
>     <xs:attribute name="a1" type="string">
>    </xs:extension>
>   </xs:simpleContent>
> </xs:complexType>
> 
> 
> > This might also be related to an exchange from last year:  
> 
> <snip
>  
> href="http://lists.w3.org/Archives/Public/xmlschema-dev/2001Oc
> t/0172.html"/>
> 
> Yes, it is.
> 
> ht
> -- 
>   Henry S. Thompson, HCRC Language Technology Group, 
> University of Edinburgh
>           W3C Fellow 1999--2001, part-time member of W3C Team
>      2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 
> 131 650-4440
> 	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
> 		     URL: http://www.ltg.ed.ac.uk/~ht/
> 
Received on Friday, 11 January 2002 06:02:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:26 GMT