Limiting element occurance by attribute values

I'm pretty sure that the answer to this lay somewhere in the use of
the <unique> and/or <key> elements. However, I am just not too clear
on how.

Here's the situation: I am working on a schema definition for software
changelogs, those loosely-formatted documents we all love from
open-source projects. As part of the schema, I have declared an
element <description>, that like schema's <documentation> can appear
at most scope-levels.

Now, here's where I'm stuck: I want <description> to be limited to one
occurrance at a given scope, but I want to allow multiples
if-and-only-if the value of an attribute called "language" is
different. (The attribute is declared with "en-US" as a default, so
the only requirement for a second and subsequent <description> block
is language="something-else".)

Were it just a matter of limiting the tag to one occurrance, that is
trivial. And I *think* I understand how to use <unique> to accomplish
this, but I'm not sure. I'd rather get some (semi-)expert advice. And
if I use <unique>, do I put it in the <complexType> that defines
<description> (which I cleverly call "descriptionType"), or do I put
it in the places where the tag <description> is actually declared as
an instance of descriptionType?

All feedback greatly appreciated.

Randy
-- 
Randy J. Ray / randy.j.ray@gmail.com
Campbell, CA

Received on Friday, 24 December 2004 02:43:15 UTC