Skip to content

settings.xsd - Required, unique and multiple tags #2

@Pyrax

Description

@Pyrax

With the structure of a server's settings.xml I have encountered an issue that I could not fully resolve. In a settings.xml there can be a number of unique tags (actually, all despite the <resource>-Tag) as well as the <resource>-Tag which can be used multiple times on the same level.
Furthermore I wanted to ensure that there's a <servername>- and <maxplayers>-Tag present in every settings.xml.

It would be easy to achieve in XSD 1.1 like shown below, however Visual Studio would not support that version:

<xs:all>
    <xs:element ref="servername" />
    <xs:element ref="maxplayers" />
    <xs:element ref="password" minOccurs="0" maxOccurs="1" />
    <!-- ... -->
    <xs:element ref="allowcefdevtool" minOccurs="0" maxOccurs="1" />
    <xs:element ref="resource" minOccurs="0" maxOccurs="unbounded" />
</xs:all>

So, the only possible options that I have discovered yet are those compromises:

  1. Use a sequence, but then the XML tags would have to be in a given order.
  2. Use a choice. In this case all tags can be used multiple times. A minimum occurence is hard to achieve. The current solution generally involves this compromise with a little "tweak" to make the former specified tags required and unique by combining it with a sequence.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions