W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2004

Limiting element occurance by attribute values

From: Randy J. Ray <randy.j.ray@gmail.com>
Date: Thu, 23 Dec 2004 16:29:53 -0800
Message-ID: <35cda21d041223162971b6aa21@mail.gmail.com>
To: xmlschema-dev@w3.org

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 J. Ray / randy.j.ray@gmail.com
Campbell, CA
Received on Friday, 24 December 2004 02:43:15 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:07 UTC