[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Attributes v Elements
- From: Duane Nickull <firstname.lastname@example.org>
- To: email@example.com, firstname.lastname@example.org
- Date: Thu, 17 May 2001 04:14:08 -0700
> This rule sounds nice, but I wonder where it comes from (I don't
> remember anything of that tone in the recommendation) and if the
> restrictions on elements do not alter it.
It comes from years of SGML and although you are technicall correct that XML
"... does not constrain the semantics, use, or (beyond syntax) names of the
element types and attributes.." I think that both common sense and common
practices both point in that direction. Also, XMI and UML also heavily
weigh in the representation of objects (not scoped to programming objects)
by this use of elements and attributes.
XML 1.0 also does not recommend against the use of mixed content but I think
you will also find that in general the best practice is to avoid it.
As far as the use of Attributes, I quote from XML 1.0:
"Attributes are used to associate name-value pairs with elements. Attribute
specifications may appear only within start-tags and empty-element tags;
thus, the productions used to recognize them appear in 3.1 Start-Tags,
End-Tags, and Empty-Element Tags. Attribute-list declarations may be used:
a.. To define the set of attributes pertaining to a given element type."
My interpretation of this means that an Attribute must have some special
meaning to the Element that contains it. The syntax associates attribute
directly with elements. You would not often use an attribute as a stand
alone part of an XML document. This is simply not common sense. Using
<value> is meaningless semantically unless you know what it referes to. If
modelled properly, there is an association with another item. A UML model
will show the relationship of that association and if there is a dependancy,
it can represent that.
> What if your adjective has a structure and needs mixed content ?
I am unclear of what you are referring to. An adjective which describes a
unique property of an element does not have any structure other than the "
name='value' " bestowed upon it by XML 1.0 syntax constraints.
> What if your adjective can have several values ?
> What if the order between your adjectives is significant ?
That is a not a function of XML itself. That is a requirement of a handler
written to make use of what the parser returns. Sure people may argue that
XML DTD's are needing additional functionality here but I belive if your XML
is modelled corectly, it should not ever be the case. Can you provide an
example where the document instance itself has a critical need to have
attributes appear in a certain order (not the end user of the document).