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

Re: A practical use case for a fixed ID attribute?

From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
Date: Mon, 10 Dec 2012 14:52:39 -0700
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-Id: <B428F6C4-CC91-4D01-B204-F15C8C600627@blackmesatech.com>
To: "Costello, Roger L." <costello@mitre.org>

On Dec 8, 2012, at 5:56 AM, Costello, Roger L. wrote:

> Hi Folks,
> In XML Schema 1.1 it is possible to declare an attribute of type ID and fix its value. For example:
> <attribute name="instructor" type="ID" fixed="Professor-Johnson" />
> Yesterday I showed that example to my class and they challenged me on the usefulness of this. 
> I could not think of a single practical use case for a fixed ID attribute.
> Do you have a practical use case for a fixed ID attribute?

The most obvious case I can think of is to require that a document have
at most one element of a given kind, even if there may be more than
one place such an element could go.

If  you imagine a document type which must, at some location or
other, have exactly one A element, exactly one B element, and
exactly one C element, but which allows each of A, B, and C in 
many different places, providing a fixed ID would be a simple way to
ensure that there is at most one of each of these element types.

You could get a similar effect by using an assertion on the document
root like "count(//A) < 2 and count(//B) < 2 and count(//C) < 2". 
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
Received on Monday, 10 December 2012 22:02:50 UTC

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