Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - multiple elements with different names but same type [Thread Next] Re: multiple elements with different names but same typeTo: Luke Graham <lukeg@----------.---.--> Date: 1/18/2005 1:07:00 PM
Hi Luke,
> I want to write something along these lines instead...
>
> <xs:element name="*" type="foo" minOccurs="0" maxOccurs="64"/>
>
> Is it possible?
No, that is not possible.
However it seems that the substitution groups are close to what you
want. For instance if you have a schema like below:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="foo"></xs:complexType>
<xs:element name="abstractFoo" type="foo" abstract="true"/>
<xs:element name="test">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="64">
<xs:element ref="abstractFoo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="a" type="foo" substitutionGroup="abstractFoo"/>
<xs:element name="b" type="foo" substitutionGroup="abstractFoo"/>
<xs:element name="c" type="foo" substitutionGroup="abstractFoo"/>
<xs:element name="d" type="foo" substitutionGroup="abstractFoo"/>
</xs:schema>
then the test element can contain 1 to 64 elements from {a, b, c, d}.
> 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"/>
This does not work like you write it, but you can have an anonymous type
like below:
<xs:element name="bar">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Hope that helps,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
www.---.com
Luke Graham wrote:
> Hello list,
>
> 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?
>
> 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.
>
From mike@s... Tue Jan 18 10:04:15 2005
Received: from bart.w3.org ([128.30.52.40])
by frink.w3.org with | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
