Cannot figure out how to model the folowing XML node with some further restrictions and requirements (described underneath). The node to model as XML Schema Definition...
Code:
<connections>
<connection type="build" port="11000" />
<connection type="admin" port="11011" />
</connections>
I want the above structure and want to model that the
connection node with type
build is required but the
connection node with type
admin is optional. Furthermore that it is only these two instances of
connection which is allowed.
I have tried to model some of it in the following XML Schema Definition...
Code:
<xsd:element name="connections">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="connection" maxOccurs="2">
<xsd:complexType>
<xsd:attribute name="type" type="connectionType" />
<xsd:attribute name="port" type="xsd:integer" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="connectionType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="build"/>
<xsd:enumeration value="admin"/>
</xsd:restriction>
</xsd:simpleType>
However it does not specify that the
connection node with type
build has to appear. One node has to appear since
minOccurs is 1 by default, but it might as well be the
admin type.
I might add that I am
not interested in renaming the
connection nodes if another solution to the above is available. Should be simple to model the problem using e.g.
connectionBuild and
connectionAdmin.
Hope someone will help me, thanks,
Jacob.