W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2001

Re: [Moderator Action] Help on substitutionGroups, abstract elements and derivations from anySimpleType

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 20 Apr 2001 10:27:30 +0100
To: Björn Hedin <bjornh@gt.kth.se>
Cc: <xmlschema-dev@w3.org>
Message-ID: <f5b3db3ly4d.fsf@cogsci.ed.ac.uk>
Björn Hedin <bjornh@gt.kth.se> writes:

> I have a problem:
> 
> I have a group which should contain a choice of a number of elements with SimpleType content. There are about 20 SimpleTypes I have defined which should be in the recommendation I'm working on. However, I want it to be possible for users of the schema to extend this group and add application specific SimpleTypes.
> 
> I think I have a solution that might work, but think it is a rather "ugly" solution.
> 
> The group is something like this (defined in the namespace labeled "imf"):
> <group name="AttributeGroup">
>   <choice>
>     <element ref="imf:ActualCopies"/>
>     <element ref="imf:Colour"/>
>     ...
>     <element ref="imf:abstract_attribute" />
>   </choice>
> </group>
> 
> The imf:abstract_attribute is a "placeholder" which allows externally defined elements to be added, but these elements must explicitly be defined as being "equal" to the imf:abstract_attribute using a substitutionGroup.
> 
> imf:abstract_attribute is defined like this:
> 
> <element name="abstract_attribute" type="anySimpleType" abstract="true" />
> 
> Then, to define new elements I do like this (in the namespace labeled "demo"):

So down to here this looks fine

> <simpleType name="NewIntegerType">
>   <restriction base="anySimpleType">
>     <simpleType>
>       <union memberTypes="integer" />
>     <simpleType>
>   </restriction>
> </simpleType>
>
> <element name="MyNewIntegerType" type="demo:NewIntegerType" substitutionGroup="imf:abstract_attribute" />

But this is bogus.  You are not allowed to derive from anySimpleType.
Just use integer as the type of your element:

<element name="MyNewIntegerType" type="integer" substitutionGroup="imf:abstract_attribute" />

> The problem is that types in a substitutionGroup must be derived
> from the "head element". I thought that all simple types were
> derived from anySimpleType, but when I try that in XSV I get an
> error message. 

Are you saying you tried what I suggested and XSV complained?  If so
that's a bug.  I'm pressed for time right now, could you send sample
schema, instance and error output to the list?


> If integers etc are not derived from anySimpleType
> (and I have understood everything else :-), then I will have to
> define my own basic simple types (like integer, dateTime etc) in the
> way I do above. Since there are about 50 pre-defined SimpleTypes I
> would have to add 350 lines to my schema if I wanted other users to
> be able to use all the pre-defined types in their extensions to the
> schema, and not have to define the pre-defined SimpleTypes
> themselves.
> 
> So, I have three questions:
> 
> 1. Does the example above work? (according to XSV it works, but it is difficult to know for sure due to the limited SimpleType validation in XSV)

That's a bug -- it shouldn't allow restriction of anySimpleType.

> 2. Are types like integers derived from anySimpleType or is that only just not implemented in XSV yet?

Should be OK.

> 3. Is there a better way to solve my problem?

I don't think so.

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, 20 April 2001 05:27:31 GMT

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