Good day stakovtsy. There was such a question, how in the XSD scheme to designate the element xs:element (any) with the parameter required = false , because there are several structures with the presence of one or another element and its absence? Or, there is a similar structure ->

  <item_make_list>EMPTY</item_make_list> <corpse_make_list>EMPTY</corpse_make_list> <corpse_make_list> <item name="charcoal" min="1" max="1" chance="5.6617"/> <item name="magic_ring" min="1" max="1" chance="34.3131"/> <item name="rp_broad_sword" min="1" max="1" chance="4.5293"/> </corpse_make_list> <additional_make_list>EMPTY</additional_make_list> <additional_make_list> <group chance="70.0"> <item name="adena" min="30" max="42" chance="100.0"/> </group> <group chance="25.7009"> <item name="apprentice's_earing" min="1" max="1" chance="30.9859"/> <item name="necklace_of_magic" min="1" max="1" chance="23.0047"/> <item name="magic_ring" min="1" max="1" chance="46.0094"/> </group> <group chance="6.6988"> <item name="stem" min="1" max="1" chance="29.1262"/> <item name="varnish" min="1" max="1" chance="14.5631"/> <item name="suede" min="1" max="1" chance="9.7087"/> <item name="silver_nugget" min="1" max="1" chance="5.8252"/> <item name="thread" min="1" max="1" chance="29.1262"/> <item name="rp_bow" min="1" max="1" chance="11.6506"/> </group> </additional_make_list> 

Then how to properly initialize the element with the parameter "EMPTY", and additionally the attributes in the absence of this parameter

    2 answers 2

    You must specify the minimum number of occurrences of the element - 0 (by default it is equal to 1)

     <xsd:element name="..." type ="..." minOccurs="0" /> 

    Also, the xsd:element has an maxOccurs attribute that specifies the maximum number of entries. By default, it is also 1. If the maximum number of entries is unlimited, then this attribute should be set to unbounded

    • Fundamentally not what you need - GenCloud
    • one
      @GenCloud Judging by your question, you need to specify the element as optional. I showed how to do it. If you need something else, then reformulate the question - Anton Shchyrov

    An alternative solution was found by introducing a new boolean parameter into the element constructor and initializing attributes with the type required=false .