- From: Jeff Rafter <jeffrafter@definedweb.com>
- Date: Wed, 6 Jun 2001 22:27:34 -0700
- To: "Noel Bush" <noel@alicebot.org>
- Cc: <xmlschema-dev@w3.org>
Noel, I don't think you can do exactly what you want-- much of what you are looking for includes co-constraints (if attribute x, then element y). Co-constraints can be expressed using a tool like Schematron in conjunction with XML Schemas (at least until 1.1.). Therefore the standard way to express this is: <xs:element name="condition"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="li"> <xs:complexType> <xs:attribute name="name"/> <xs:attribute name="value"/> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="name"/> <xs:attribute name="value"/> </xs:complexType> </xs:element> And leave the other constraints up to another schema language or the application itself. Ways of wriggling: I am not sure if I know the answer-- but it seems you could utilize the substitution group feature of XML Schemas to accomplish your goal. Simply create the condition element with the type BaseListType. Declare the BaseListType as a complexType which is initially an empty sequence. Then extend the BaseListType with the multiple forms of the condition element (some containing li content). Then utilize xsi:type in your document, or decalre additional condition styled elements as part of the substitution group for condition. Of course then the name is changing. Finally you could utilize the any element-- though you then begin to lose complete control. Utilizing Schematron in conjunction is the best practice... oh wait.... I have a link which says so: http://www.xfront.com/ExtendingSchemas.html Good Luck, Jeff Rafter Defined Systems http://www.defined.net XML Development and Developer Web Hosting ----- Original Message ----- From: "Noel Bush" <noel@alicebot.org> To: <xmlschema-dev@w3.org> Sent: Saturday, June 02, 2001 2:02 PM Subject: multiple type definitions for elements with the same name > Hello; I am trying to create a schema for AIML, a language used by the > Alicebot engine (see http://alicebot.org). The engine currently supports > the following multiple forms of a "condition" tag: > > FORM: multi condition tags: > > <category> > <pattern>I AM BLOND</pattern> > <template>You sound very > <condition name="gender" value="female">attractive.</condition> > <condition name="gender" value="male">handsome.</condition> > </template> > </category> > > FORM: list-condition tag: > > <category> > <pattern>I AM BLOND</pattern> > <template>You sound very > <condition> > <li name="gender" value="female">attractive.</li> > <li name="gender" value="male">handsome.</li> > </condition> > </template> > </category> > > FORM: single name list-condition tags > > <category> > <pattern>I AM BLOND</pattern> > <template>You sound very > <condition name="gender"> > <li value="female">attractive.</li> > <li value="male">handsome.</li> > </condition> > </template> > </category> > > FORM: single name list-condition tags with default list-condition > > <category> > <pattern>I AM BLOND</pattern> > <template>You sound very > <condition> > <li name="gender" value="female">attractive.</li> > <li>handsome.</li> > </condition> > </template> > </category> > > It seems to me, especially after looking at > http://www.w3.org/TR/xmlschema-1/#cos-element-consistent, that this is just > impossible. No amount of wriggling lets me describe this in XML schema > language. At some point I have to declare an <xs:element name="li"> in > multiple places, with multiple definitions. > > > Is there any way to do this? > > Thanks in advance for any assistance. > > Noel Bush > ALICE AI Foundation > http://alicebot.org >
Received on Thursday, 7 June 2001 01:27:53 UTC