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...
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...