|
|
|
|
|
by lisper
4048 days ago
|
|
> I really do not see anything useful in having attributes That's because you chose examples that show attributes at their worst. Suppose that instead of a document with a single author you instead had a document to which many people contributed, and you wanted to mark it up to show who wrote which section. Using attributes (and identifiers) you would have, e.g. <author id=Bob>[info about Bob]</author>
<author id=Alice>[info about Alice]</author>
<span author=Bob>This part was written by Bob</span>
<span author=Alice>and this part was written by Alice</span>
<span author=Bob>and this part was written by Bob again.</span>
This example also highlights why it is sometimes NECESSARY to use identifiers in order to produce the semantically correct structure. Suppose you put all the author information in-line as you suggest. The result would look something like this: <span><author><name>Bob</name>[info about Bob]</author>This part was written by Bob</span>
<span><author><name>Alice</name>[info about Alice]</author>This part was written by Alice</span>
<span><author><name>Bob</name>[info about Bob]</author>This part was written by Bob</span>
Were the first and third parts written by the same person, or by two different people whose names both happen to be Bob? If you put everything in-line there is no way to express that two pieces of structure are intended to be EQ to each other. |
|
I already mentionned that with a Lisp like data-format, shared sub-expressions could be denoted using CL's reader variables:
I do not claim that this is the most appropriate solution in all cases, just that we are not forced to introduce indirection levels when unnecessary. Now, if I am using Lisp and I want to introduce external references to authors described in other documents, I could introduce a meta-data with an appropriate semantical structure: This would be a practical way to encode a precise location in a tree in an external file. And I could use this form everywhere I need to reference an object. Also, the tree-path notation is handy because there is no distinction between an attribute or an element, just which branch to take at each step from the root.Now, with XML attributes, I would typically have an "xref" attribute. How can we model xref attributes? If we wanted to have structured data, we would need to create external tags with the same concepts as above, like <pathname>, create a local identifier for each xref and refer indirectly to each xref using their local identifier: because we can only put strings. I mean:
Or, we do as everybody and encode it like for XMI, or ECORE, or any other custom format, with a complex string, hoping that HTML entities are properly escaped.Besides, you failed to notice that you had <author> tags, which precisely goes against your idea that there should be a place for "meta-data" and a place for "data": effectively, authors are now part of the content of the document, and are not only meta-informations.
If you think my examples are artificial, open the source code of this page, and observe how any kind of complex information written in attributes has to be properly escaped to bypass the limitation of stringly-typed data:
Notice how you need to escape HTML entities in inline javascript attributes (onclick) but not on script tags. Why are inline javascript not tags instead?(see http://stackoverflow.com/questions/8749001/escaping-html-ent...).
Whatever example you choose, you cannot deny the fact that attributes are not given the same rights as elements, because the way they do not allow to contain structured data or cannot have meta-attributes themselves.