OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] XML attributes are weird

It's a perennial question.

Yes, attributes are ugly from a parsing perspective.

Yes, attributes are ugly from the perspective of clean data design, for
at least from the perspectives of some understandings of what "clean
data designs" are.

Yes, there is no way to decide, at least from first principles in a
computer-sciencey fashion, whether a datum is best represented as an
attribute or as content.

Yes, this undecidability has been decried for decades.  An early
implementer at Ohio State U. told Charles Goldfarb, in my presence in
1987-88, that he obviously didn't understand the science of parsing,
because she was able to write an LR(1) parser for all the important
aspects of SGML, and, by the way, attributes weren't among the important
aspects because one can use data content for every one of the same
purposes.  This was so obvious to her -- that her approach and mindset
was more informed and better in every way -- that it didn't even occur
to her that she might be missing some boat, somewhere.

That was an eye-opening experience for me, but it would not be the last
time I would see such assumptions being made by people who thought they
knew better than the designer, who hadn't bothered to understand the
design goals, and who didn't wonder whether those goals might be important.

No, I don't think Charles was thinking about attribute grammars, but
you'd have to ask him.  It's just my impression.  I say this because I
see in Wikipedia the following definition of "attribute grammar"...

"An attribute grammar is a formal way to define attributes for the
productions of a formal grammar, associating these attributes to values.
The evaluation occurs in the nodes of the abstract syntax tree, when the
language is processed by some parser or compiler."

...and I fail to see how that idea is related to what I understand to be
the essential nature and purpose of attributes in XML nee SGML.
(However, I can easily imagine XML attributes being used for such a
purpose in some applications.  Moreover, SGML has some rather complex
features that are reminiscent of attribute grammars, but those are gone
from XML, and AFAIK those features are not missed very much, if at all.
 Speaking for myself, I don't miss them.)

I've had a lot of time to think about the question of attributes, and
I've had many occasions to wonder about it.  I can't speak for Charles,
or for Bill Davis, or for the other deciders about the original design
requirements.  However, I think I can now articulate an explanation for
the necessity of attributes that satisfies me, and particularly that
satisfies my need to know whether a class of datum should be
interchanged as element content or as the value of an attribute.

I doubt that my current explanation would have satisfied that early
"SGML parser" implementer, though.  It's very hard to step outside the
box of one's profession's doctrines.

One of the pieces of the puzzle turns out to be understanding that the
generic identifier of an element (the element type name) is best
understood as the value of the special attribute, one that's always
present, and that has no name.  Once you internalize that idea, you
begin to understand that data about data (metadata) are not optional,
even though they are absolutely data like any other data.  The
distinction between metadata and data cannot be dismissed or ignored,
even on Computer-Sciencey grounds.

The other piece of the puzzle is to understand that the difference
between data and metadata is entirely a matter of human perspective.

Data in the absence of context are meaningless, without purpose or
importance.  In the broadest sense, attributes endow elements with some
hints about context.  The choice of whether a datum is meta or not is a
rhetorical one.  It's a human thing.  It has little or nothing to do
with computer science, since computer science generally seeks to avoid
that kind of thing.  It's not "hard science".

But soft science and the arts are pretty important.  Indeed, we human
beings can't live without them.  Rhetoric isn't so much a science as an
art.  I would argue that the same observation applies to human
communication in general: it's art.

So it doesn't bother me, any more, that XML attributes are "ugly".  Nor
am I offended when someone observes the truth of it aloud.  I think a
tolerance for such ugliness is the beginning of wisdom.  "Nihil humanum
alienum mihi est." ("Nothing human is alien to me.")  It's a state of
being I strive to achieve.  I hope and believe others will strive for
the same goal.  I think that attitude is a prerequisite for
effectiveness and pleasure at the infrastructure level of human
communication, where XML developers work.

On 12/21/2013 03:39 PM, Costello, Roger L. wrote:
> Hi Folks,
> Why did the founding fathers of XML create attributes?
> XML attributes are weird. 
> They make XML documents dirty, messy, cluttered, and, well, ugly.
> XML elements are a perfectly satisfying way of defining name-value pairs. XML attributes is a special (i.e., extra, extraneous, redundant) way of including name-value pairs in the XML. That's awful.
> Unless ....... the creators of XML intended attributes for another purpose.
> I am reading a wonderful book on parsing and it talks about extending grammars with attributes; those attributes are used to specify the grammar's semantics.
> Hey, XML is a grammar: that's what XSD and RNG are all about, they define grammars.
> So maybe what the founding fathers of XML really had in mind with attributes is that they be used to enrich XML grammars with semantic information?
> Are any of the original founding fathers of XML out there? What were you thinking when you put attributes into XML? Perhaps you were thinking of attribute grammars?
> /Roger
> _______________________________________________________________________
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS