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

RE: multiple elements with different names but same type

From: Michael Kay <mike@saxonica.com>
Date: Tue, 18 Jan 2005 10:04:09 -0000
To: "'Luke Graham'" <lukeg@multitrode.com.au>, <xmlschema-dev@w3.org>
Message-Id: <E1CqqDe-0000xp-00@ukmail1.eechost.net>

> 
> I have a problem with some schemas that Im writing. They look 
> as follows...
> 
> <xs:complexType name="foo"/>
> 
> <xs:element name="_1" type="foo"/>
> <xs:element name="_2" type="foo"/>
> .....
> 
> I want to write something along these lines instead...
> 
> <xs:element name="*" type="foo" minOccurs="0" maxOccurs="64"/>
> 
> Is it possible?

No. Is this a vocabulary you are designing, or one that already exists? It
looks as if it's trying to capture information by means of structured
element names, which is always a bad idea: use attributes instead.
> 
> And... I want to give a range to a simple integer, without deriving a 
> new type -
> 
> <xs:element name="bar" type="xs:int" minInclusive="0" 
> maxInclusive="10"/>
> 
> Do I really have to derive a new type each time? That seems excessive.

Each of the elements has a different type, so it seems reasonable to
acknowledge the fact. You can use anonymous types if you want. The syntax is
long-winded but at least it doesn't try to hide what's happening:

<xsl:element name="bar">
  <xs:simpleType>
    <xs:restriction base="xs:integer">
       ...

Michael Kay
http://www.saxonica.com/
Received on Tuesday, 18 January 2005 10:04:15 GMT

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