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

At 2012-12-08 12:56 +0000, Costello, Roger L. wrote:
>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?

When processing a given document for different purposes, perhaps 
during the life cycle of the document, you may wish to mark the 
document as having a particular state.  But your document might be 
read-only, so you can't actually touch the document in order to 
change its state.

Or, you have different consumers of the one document and they each 
perceive the document as having a different state, such that you 
cannot modify the document even if it were not read-only.

Using a fixed attribute in the schema, the post schema-validation 
information set (PSVI) will contain that attribute for processing by 
XSLT or whatever downstream processor you may have.

Thus each consumer of the document has a slightly different schema 
(using include and import for common bits) but can share the same 
downstream processes.  The PSVI is different for each consumer.

While one could also use a defaulted attribute, the risk is that 
someone has actually written in an attribute value for that state, in 
which case the PSVI would not reflect the schema-defaulted value but 
the instance-specified value.  When using a fixed attribute, the 
system would burp if it found a contradictory value specified in the document.

Not that I've had to do this myself, but I hope that scenario does 
not seem beyond belief.

. . . . . . . . . . Ken

p.s. There is also some legacy to #FIXED, as it was available in 
DTDs, which was when I first considered the above scenarios in SGML 
applications.  I've seen #FIXED used in XML DTDs for namespace 
declarations, thus ensuring that no other namespace might 
inadvertently be used in the post DTD information set.


--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/x/
G. Ken Holman                   mailto:gkholman@CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Received on Saturday, 8 December 2012 13:26:47 UTC