- From: <MarkH@i2.co.uk>
- Date: Tue, 9 Jan 2001 12:10:08 -0000
- To: xmlschema-dev@w3.org
Before I try this, any comments on its feasibility... I want to define a family of schemas - not too rigorously - ie a base schema (effectively a common structure) and set some rules about how this can be customised, and provide people with some help in keeping to these rules using schema validation. My idea was to use a base schema which includes the following structure... <myDocument> <items> <!-- a collection of zero or more items of different types --> <item id='e0001' type='person'> <property name='comment' value='A software consultant'/> <property name='firstName' value='Mark'/> <property name='lastName' value='Hughes'/> </item> <item id='e0002' type='vehicle'> <property name='comment' value='Involved in accident'/> <property name='make' value='Ford'/> <property name='color' value='Red'/> </item> <!-- An item for which no suitable 'type' has been defined (not anticipated in the ready made types) --> <item id='e0003' type='other'> <property name='comment' value='A free lunch'/> <property name='calories' value='0'/> </item> <!-- ...etc... --> </items> </myDocument> I wanted to be able to provide some ready made types, such as person and vehicle, and to allow a user to extend this with their own types. The ready made types would also be flexible in that other aribtrary properties (not anticipated by the designer) would be allowed. doc-schema.xsd would define <myDocument> with <items></items> as a collection of zero or more <item> elements with different values for 'type'. standard-types.xsd would define some ready made types for inclusion. These would have mandatory "comment" property, but allow an arbitrary number of property elements without predefined settings for 'name'. Hence the schema would allow arbitrary <property name='' value=''/> elements, but mandate that at least one had name='comment'. user-schema.xsd would include doc-schema.xsd, standard-types.xsd (and other files of types as needed) and redefine the <items> structure to allow the full range of types wanted. When defining a type, I wanted to be able to make certain properties mandatory, but since "attributes are not part of the content model in XML Schema v1.0" (Henry's post "Re: redefinition errors" Jan 08, 2001) I can't do this in the above structure, and would have to have property elements with different property names (ie "<comment>A software consultant</comment>" and "<firstName>Mark</firstName>" and so on). I think this also means that the item elements will need different names (is this true?) and so I would end up with a structure like this: <myDocument> <items> <!-- a collection of zero or more different item types --> <personItem id='e0001'> <comment>A software consultant</comment> <firstName>Mark</firstName> <lastName>Hughes</lastName> </item> <vehicleItem id='e0002'> <comment>Involved in accident</comment> <make>Ford</make> <color>Red</color> </vehicleItem> <!-- An item for which no suitable 'type' has been defined (not anticipated in the ready made types) --> <otherItem id='e0003'> <comment>A free lunch</comment> <calories>0</calories> </otherItem> <!-- ...etc... --> </items> </myDocument> And to arrive at this point I propose: doc-schema.xsd would define <basicDocument><items></items></basicDocument> standard-types.xsd would define some ready made elements for inclusion in <items>. These would wrap a mandatory <comment> element, and be able to contain an arbitrary number, of arbitrarily named simpleType elements (ie "<someName>value</someName>") to represent unanticipated properties. Hence the schema would allow arbitrary "<someName>value</someName>" elements inside each item, but mandate that at least one "<comment>a comment for the item</comment>" was included. user-schema.xsd would include doc-schema.xsd, standard-types.xsd (and other files of types as needed) and define <myDocument> by redefining the <items> element to allow the full range of types wanted. Questions: 1) Will this work or have I missed something (again!)? 2) In particular, is it possible an I allow arbitrary additional elements after <comment></comment>, or must I anticipate all the possible element names. In other words, could someone create a document which has <someElementWhichDoesNotAppearInAnySchemaFile>blah</someElementWhichDoesNotA ppearInAnySchemaFile> after <comment></comment>? 3) Do I have to use different names for the item elements? I think I have to because they will be different types, and you can't mix types with the same element name) Thanks Mark -- Mark Hughes Agile HTML Editor http://www.agilic.com
Received on Tuesday, 9 January 2001 07:17:21 UTC