Requiring one element without attributes XSD



I'm just getting started with XSD trying to validate an XML configuration file I've been using. Each configuration specifies a default configuration for a server, which can be overridden on a per-server basis.


This is the default:



<server>
<cpu>65</cpu>
// Other configuration
</server>


This is an (optional) override:



<server key="2">
<cpu>55</cpu>
</server>


I'm not sure how to build the XSD to support 1 required element without attributes, and 0-n elements with attributes given that they have the same name. With different names, it's a much easier matter, but that seems messy given that the elements are otherwise identical.


Edit:


To address @kjhughes's request, here's the simplified document structure:



<configuration>
<target>Production</target>
<responsible>email@email.com</responsible>
<server>
<cpu>65</cpu>
</server>
<server key="2">
<cpu>55</cpu>
</server>
</configuration>

No comments:

Post a Comment