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

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