- From: <Simon.Cox@csiro.au>
- Date: Thu, 10 Jan 2002 10:10:27 +0800
- To: xmlschema-dev@w3.org
OK - so the contradiction is between the third sub-clause of http://www.w3.org/TR/xmlschema-2/#defn-rep-constr and the <simpleContent><restriction><simpleType> pattern towards the top of the summary box in http://www.w3.org/TR/xmlschema-1/#declare-type You say that an erratum will be issued. Any preview as to which way it will go? This could have a significant effect on a lot of designs. _____ 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 Wednesday, 9 January 2002 21:17:32 UTC