Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: multiple elements with different names but same type

From: George Cristian Bina <george@---------.--->
To: 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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent