xml - XSD: reuse sub-elements of complexType? -


i have defined following 2 types in xsd-file:

<complextype name="primitive">   <attribute name="seq_num" type="int"/>   <element name="prim_to" type="int"/> </complextype>   <complextype name="configdata">   <sequence>     <element name="enable" type="boolean"/>     <element name="type" default="int"/>    </sequence> </complextype> 

both types used in number of definitions, i.e. rather not change these them. define new element set extends primitive , contains sub-elements of configdata. xml-file element (please note, enable , type @ same level prim_to):

<set seq_num="1234">   <prim_to>22</prim_to>   <enable>true<enable>   <type>42</type> </set> 

i declare set following way:

<element name="set">   <complextype>     <complexcontent>       <extension base="primitive">         <sequence>           <element name="config" type="configdata"/>         </sequence>       </extension>     </complexcontent>   </complextype> </element> 

in case xml-file this:

<set seq_num="1234">   <prim_to>22</prim_to>   <config>     <enable>true<enable>     <type>42</type>   </config> </set> 

my challenge define set in such way extends primitive , contains sub-elements of configdata - not contain element of type configdata. xml-file above question of not having 2 'config'-tags. possible in xsd? highly appreciate hints.

thanks in advance,
witek

a type can extend single other 1 (in other words, there no multiple inheritance). so, set element can extend configdata (with xsd:extension) , have additional elements, or can extend type , copy configdata elements extend it. can use groups avoid redundancy.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -