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


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Attributes v Elements

Duane Nickull wrote:
> > 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.

I have great respect for best practices painfully learned during years
of labor, but I also think that we shouldn't make them hard rules if we
don't want to block any innovation ;=) ...

I do personally see them only as 2 options to serialize information, one
of them being more concise and the other more extensible (see below).

> 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.

Mixed content is a great asset for some applications (it's hard to
imagine XHTML without mixed content).

> 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.

My mistake, "complex type" would have been more accurate than "mixed

Attributes such as "alt" or "title" could for example be more expressive
with richer content.

<img  src="ebXML.gif">
    This is the logo of <a href="http://www.ebxml.org">ebXML</a>, 
    a project that will <em>radically</em> change the way to do 
    business on the web.

The advise I give in my training is that if a value may, in a later
edition of a vocabulary, become structured and require a complex type,
an element should be preferred.

Generally speaking I think elements are much more flexible to use and
that by choosing an element, you get a better extensibility.
> > What if your adjective can have several values ?
> enumerated lists.

I do not recommend enumerated lists since they cannot easily be
processed with XSLT or queried with XPath and they require using non XML
libraries with other languages.
> > 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).

No, I can't, probably because in these case elements have been used
instead of attributes ;=).
> Cheers!
> Duane Nickull
> ------------------------------------------------------------------
> The xml-dev list is sponsored by XML.org, an initiative of OASIS
> <http://www.oasis-open.org>
> The list archives are at http://lists.xml.org/archives/xml-dev/
> To unsubscribe from this elist send a message with the single word
> "unsubscribe" in the body to: xml-dev-request@lists.xml.org

See you in Berlin for XML Europe 2001:
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org