XSD - best way to do specify several similar elements

B

beethoven_forever

I'm writing a schema and want a certain element to be specified to have
zero or more of four, similar child elements like so...

<object>
<integer name="Foo" value="-14"/>
<flag name="IsBar" value="true"/>
<flag name="IsWeighty" value="false"/>
<string name="Doofus" value="cuddly"/>
<script name="OnJump" value="JumpHandler"/>
</object>

....where each element's "value" attribute is required to have a
different data type (xs:integer for integer, xs:boolean for flag,
xs:string for string and script).

My question is, how do I avoid rewriting almost duplicate code (below)
for each element?

<xs:element name="integer" minOccurs="0" maxOccurs="unbounded">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:integer" use="required"/>
</xs:element>

<xs:element name="flag" minOccurs="0" maxOccurs="unbounded">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:boolean" use="required"/>
</xs:element>

....etc...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,249
Members
46,845
Latest member
GygaKnight

Latest Threads

Top