xsd - Is it preferred to define a separate plural complexType for multiple singular elements -


is there established standard inlining trivial plural complextypes vs. defining them separately?

in detail: when defining xml schemas encounter cases want 1 element contain multiple child elements of same single type. example schema describes table in database has fields element can contain 1 or more field elements. can either create inline complextype within definition of plural fields element:

<xs:element name="fields" minoccurs="1" maxoccurs="1">   <xs:complextype>     <xs:sequence>       <xs:element name="field" type="table-field"                    minoccurs="1" maxoccurs="unbounded" />     </xs:sequence>   </xs:complextype> </xs:element> 

or can separately define trivial fields type , use that:

<xs:element name="fields" type="table-field-collection" minoccurs="1" maxoccurs="1">  <!-- elsewhere: --> <xs:complextype name="table-field-collection">   <xs:sequence>     <xs:element name="field" type="table-field" minoccurs="1" maxoccurs="unbounded" />   </xs:sequence> </xs:complextype> 

the first approach creates more messy markup anonymous types, while second creates lots of trivial complextypes. there concensus on approach preferred?

there isn't established standard this. there 3 choices:

  1. "fields" must defined complex type , reused (table-field-collection above)
  2. "fields" element anonymous sub-type
  3. there no fields element. instead, "field" repeats within parent element.

i have specified modelling guidelines number of firms , used of these patterns. more recently, i'm tending towards third - encapsulating fields element not have semantic meaning, other making nice grouping when viewing documents in graphical tools. if process using jaxb, you'd annoyed fields there - 1 more thing can null.

if want ask 1 relevant question technical point of view, this: want able inherit table-field-collection , override using xsi:type, or reuse it? if yes, go complex type. if no, go whatever prefer style-wise.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -