[comp.text.sgml] Class vs. Instance Attributes

eswarp@dosai.East.Sun.COM (Eswar Priyadarshan - Sun BOS Software) (05/22/91)

I have another in the series of philosophical questions being asked
about attributes. In the application we're contemplating, we
seem to be running into what could be viewed as 2 types of
attributes of an element:
	1. attributes whose value is the same for all instances of the
	   element. That is, the attributes are used to distinguish
 	   one element from all others. For example, all text tagged
  	   Foo is to be considered confidential. 

	   The DTD would define an attribute for Foo whose only/default
	   value would be, to use the example, CONFIDENTIAL=Yes.

	2. attributes whose value differs from instance to instance. That is,
	   the DTD would define a set of possible values an attribute
	   can have for text tagged Foo. Each instance of the element Foo
	   could have a different attribute value within that set.

Is the use of an attribute in case 1 ok?

Seems to me that instead of using attributes in case 2, nested tags should
be used. Use attributes only when talking about every instance of an
element?

Comments?


Eswar
(eswarp@East.Sun.COM)

enag@ifi.uio.no (Erik Naggum) (05/24/91)

Eswar Priyadarshan - Sun BOS Software writes:
| 
|    I have another in the series of philosophical questions being asked
|    about attributes. In the application we're contemplating, we
|    seem to be running into what could be viewed as 2 types of
|    attributes of an element:
|
| 	   1. attributes whose value is the same for all instances of the
| 	      element. That is, the attributes are used to distinguish
| 	      one element from all others. For example, all text tagged
| 	      Foo is to be considered confidential. 
| 
| 	      The DTD would define an attribute for Foo whose only/default
| 	      value would be, to use the example, CONFIDENTIAL=Yes.

Apart from picking on the choice of attribute name and value (I think
it makes more sense to call it "security=confidential"), this can be
done to "subtype" a tag to the application.  In such as case, "#FIXED
confidential" is probably not a bad choice for the default value.

| 	   2. attributes whose value differs from instance to instance.
| 	      That is, the DTD would define a set of possible values
| 	      an attribute can have for text tagged Foo. Each instance
| 	      of the element Foo could have a different attribute
| 	      value within that set.
| 
|    Is the use of an attribute in case 1 ok?

It's being used with the #FIXED form in HyTime and SMDL, which leads
me to believe it's probably OK.  :-)

|    Seems to me that instead of using attributes in case 2, nested
|    tags should be used. Use attributes only when talking about every
|    instance of an element?

This seems to be a philosophical point worth considering.  Steve
DeRose's note is to the point, here.  ID's in particular vary between
instances of elements.  IDREF(S) also need attributes to work.

My stand in this debate is that attributes tell something _about_ a
given element, which is neither structural nor content.  As Steve
point out, the type of a list (e.g. bulleted) naturally belongs in an
attribute.  (Whether that attribute is added explicitly or at link
time is another matter.  For formatting-oriented things, I would
probably favor LINKs, which make things much easier to change.)

The question still remains:  How do you figure out what's content,
attribute, and structure?

</Erik>
--
Erik Naggum             Professional Programmer            +47-2-836-863
Naggum Software             Electronic Text             <ERIK@NAGGUM.NO>
0118 OSLO, NORWAY       Computer Communications        <enag@ifi.uio.no>