Another Word For It Patrick Durusau on Topic Maps and Semantic Diversity

June 1, 2015

The Silence of Attributes

Filed under: Topic Maps,XML — Patrick Durusau @ 3:22 pm

I was reading Relax NG by Eric van der Vlist, when I ran into this wonderful explanation of the silence of attributes:

Attributes are generally difficult to extend. When choosing from among elements and attributes, people often base their choice on the relative ease of processing, styling, or transforming. Instead, you should probably focus on their extensibility.

Independent of any XML schema language, when you have an attribute in an instance document, you are pretty much stuck with it. Unless you replace it with an element, there is no way to extend it. You can’t add any child elements or attributes to it because it is designed to be a leaf node and to remain a leaf node. Furthermore, you can’t extend the parent element to include a second instance of an attribute with the same name. (Attrbutes with duplicate names are forbidden by XML 1.0.) You are thus making an impact not only on the extensibility of the attribute but also on the extensibility of the parent element.

Because attributes can’t be annotated with new attributes and because they can’t be duplicated, they can’t be localized like elements through duplication with different values of xml:lang attributes. Because attributes are more difficult to localize, you should avoid storing any text targeted at human consumers within attributes. You never know whether your application will become international. These attributes would make it more difficult to localize. (At page 200)

Let’s think of “localization” as “use a local identifier” and re-read that last paragraph again (with apologies to Eric):

Because attributes can’t be annotated with new attributes and because they can’t be duplicated, they can’t use local identifiers like elements through duplication with different values of xml:lang attributes. Because attributes are more difficult to localize, you should avoid storing any identifiers targeted at human consumers within attributes. You never know whether your application will become international. These attributes would make it more difficult to use local identifiers.

As a design principle, the use of attributes prevents us from “localizing” to an identifier that a user might recognize.

What is more, identifiers stand in the place of or evoke, the properties that we would list as being “how” we identified a subject, even though we happily use an identifier as a shorthand for that set of properties.

While we should be able to use identifiers for subjects, we should also be able to provide the properties we see those identifiers as representing.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress