Re: XML: How to require either or both of two child elements, but prevent both missing?
Hi,
thanks everybody for the responses and help. I am only just back from a trip so I could not respond earlier.
I agree that the:
choice A_required_with_B_optional B_required /choice
approach is working (albeit it makes the schema a bit difficult to read). The suggestions to put a minOccurs on the choice compositor containing optional elements is not working: having no element is fine for schema (at least with validator built into xmlspy). Also it could lead to an A-A sequence.
James: Yes, having <Parent><A/><A/></Parent> is undesirable, it should really be a choice of two alternative expressions of a fact.
Examples are where a definition may either be inline directly given free-form text or a URI pointing to another place, or both, but not neither. Two inline definition elements would be difficult to interpret (whats the difference between the two? Semantics of using one or multiple?...) In this example multiple URIs would in fact be allowable, but in other examples not).
Pavel: You are right about additional validation in xslt. It is needed elsewhere already, but work on that has to come later.
Thanks again
Gregor ---------------------------------------------------------- Gregor Hagedorn (G.Hagedorn@bba.de) Institute for Plant Virology, Microbiology, and Biosafety Federal Research Center for Agriculture and Forestry (BBA) Koenigin-Luise-Str. 19 Tel: +49-30-8304-2220 14195 Berlin, Germany Fax: +49-30-8304-2203
Often wrong but never in doubt!
participants (1)
-
Gregor Hagedorn