Hi all,
I have a question to XSD and hope that someone here can help me (it's quite urgent...)
I have an XML element 'parent' which can have subelements of three different types: 'child_alpha', 'child_beta' and 'child_gamma'. The occurrence of the single subelements is not restricted: every subelement may appear an unbounded number of times or may not appear at all. But at the same time I want to force the element 'parent' to have at least one subelement. Is this possible?
Example:
is ok,
is ok, while
is not permitted.
I hope my explanation of the problem is clear: I don't want to force a certain subelement, say 'child_alpha', to appear at least once, because 'child_alpha' may also not appear. But I want that at least one of the three possible subelements appears inside the 'parent' element.
I have checked some XML Schema tutorials, but I have only found how to restrict the occurrence of a certain element - not how to restrict the occurrence of subelements.
Does somebody know a workaround to my problem?
Thank you very much in advance for your answers!!
Simon
I have a question to XSD and hope that someone here can help me (it's quite urgent...)
I have an XML element 'parent' which can have subelements of three different types: 'child_alpha', 'child_beta' and 'child_gamma'. The occurrence of the single subelements is not restricted: every subelement may appear an unbounded number of times or may not appear at all. But at the same time I want to force the element 'parent' to have at least one subelement. Is this possible?
Example:
Code:
<parent name='p'>
<child_alpha>1000</child_alpha>
<child_beta>100</child_beta>
<child_alpha>100</child_alpha>
<child_alpha>10000</child_alpha>
</parent>
Code:
<parent name='p'>
<child_gamma>1000000</child_alpha>
</parent>
Code:
<parent name='p'>
</parent>
I hope my explanation of the problem is clear: I don't want to force a certain subelement, say 'child_alpha', to appear at least once, because 'child_alpha' may also not appear. But I want that at least one of the three possible subelements appears inside the 'parent' element.
I have checked some XML Schema tutorials, but I have only found how to restrict the occurrence of a certain element - not how to restrict the occurrence of subelements.
Does somebody know a workaround to my problem?
Thank you very much in advance for your answers!!
Simon